{"id":676,"date":"2011-08-26T13:40:12","date_gmt":"2011-08-26T13:40:12","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2011\/08\/26\/using-phpmailer-to-send-mail-through-php\/"},"modified":"2025-03-31T12:47:48","modified_gmt":"2025-03-31T16:47:48","slug":"using-phpmailer-to-send-mail-through-php","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/","title":{"rendered":"Using PHPMailer to Send Mail through PHP"},"content":{"rendered":"<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png\" alt=\"PHPMailer - Send Email From PHP\" class=\"wp-image-94056\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png 1024w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-300x158.png 300w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-768x403.png 768w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP.png 1200w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/figure>\n\n\n\n<p>PHPMailer is a highly popular, actively developed email-sending library for <a href=\"https:\/\/www.inmotionhosting.com\/php-hosting\">PHP hosting<\/a>. And it\u2019s open source. <\/p>\n\n\n\n<p>Below, we\u2019ll give you a quick and easy example of a working script you can use in your local development environment or live on your InMotion Hosting server.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#install\">Install PHPMailer<\/a><\/li>\n\n\n\n<li><a href=\"#add\">Add PHPMailer To Application<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"alert alert-info\">For more information about PHPMailer, or to contribute, check out the <a href=\"https:\/\/github.com\/PHPMailer\/PHPMailer\">PHPMailer GitHub page<\/a>. Looking for a top-notch <a href=\"https:\/\/www.inmotionhosting.com\/php-hosting\">PHP web host<\/a>? You\u2019ve come to the right place. <\/p>\n\n\n\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/JltHLzkghmY\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install\">Install the PHPMailer Dependencies<\/h2>\n\n\n\n<p>You may be excited to get this code into your app, but first you need to make sure you\u2019ve installed the necessary code library. <\/p>\n\n\n\n<p>For this example, we\u2019re going to be installing PHPMailer with Composer, since that is the preferred method for a great many PHP developers. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted src src-bash\">composer require phpmailer\/phpmailer\n<\/pre>\n\n\n\n<p>That\u2019s it! If you don\u2019t have one already, composer will create your \u201cvendor\u201d directory and populate your autoload file. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"add\">Add The Code to Your App<\/h2>\n\n\n\n<p>Now is the fun part. But before running this code, make sure to change some of the example text we used below with your own information. <\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th class=\"has-text-align-left\" data-align=\"left\" scope=\"col\">Sample<\/th><th class=\"has-text-align-left\" data-align=\"left\" scope=\"col\">Replace with<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-left\" data-align=\"left\">robot@example.com<\/td><td class=\"has-text-align-left\" data-align=\"left\">Your sender email address<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">mail.example.com<\/td><td class=\"has-text-align-left\" data-align=\"left\">Your SMTP server name<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">\u2018password\u2019<\/td><td class=\"has-text-align-left\" data-align=\"left\">The sender email password<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">joe@example.com<\/td><td class=\"has-text-align-left\" data-align=\"left\">The recipient email address<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Name of sender<\/td><td class=\"has-text-align-left\" data-align=\"left\">Desired sender name<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">Name of recipient<\/td><td class=\"has-text-align-left\" data-align=\"left\">Desired recipient name<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Once you have switched out the example text, make sure to select the right development mode. This code can be used on your local server or a live production environment. <\/p>\n\n\n\n<dl class=\"org-dl\">\n<dt>For local development<\/dt><dd>keep the <code>$developmentMode<\/code> variable set to <code>true<\/code><\/dd> <dt>For live server<\/dt><dd>change the <code>$developmentMode<\/code> variable to <code>false<\/code><\/dd><\/dl>\n\n\n\n<p>We\u2019re ready to begin. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted src src-php\"><span style=\"color: #483d8b;\">&lt;?php<\/span>\n\n<span style=\"color: #a020f0;\">require<\/span> <span style=\"color: #8b2252;\">\"vendor\/autoload.php\"<\/span>;\n\n$<span style=\"color: #a0522d;\">robo<\/span> = <span style=\"color: #8b2252;\">'robot@example.com'<\/span>;\n\n<span style=\"color: #a020f0;\">use<\/span> <span style=\"color: #228b22;\">PHPMailer\\PHPMailer\\PHPMailer<\/span>;\n<span style=\"color: #a020f0;\">use<\/span> <span style=\"color: #228b22;\">PHPMailer\\PHPMailer\\Exception<\/span>;\n\n\n$<span style=\"color: #a0522d;\">developmentMode<\/span> = <span style=\"color: #008b8b;\">true<\/span>;\n$<span style=\"color: #a0522d;\">mailer<\/span> = <span style=\"color: #a020f0;\">new<\/span> <span style=\"color: #228b22;\">PHPMailer<\/span>($<span style=\"color: #a0522d;\">developmentMode<\/span>);\n\n<span style=\"color: #a020f0;\">try<\/span> {\n    $<span style=\"color: #a0522d;\">mailer<\/span>-<span style=\"color: #008b8b;\">&gt;<\/span><span style=\"color: #a0522d;\">SMTPDebug<\/span> = <span style=\"color: #000000; background-color: #ffffff;\">2<\/span>;\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #000000; background-color: #ffffff;\">isSMTP<\/span>();\n\n    <span style=\"color: #a020f0;\">if<\/span> ($<span style=\"color: #a0522d;\">developmentMode<\/span>) {\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">SMTPOptions<\/span> = [\n        <span style=\"color: #8b2252;\">'ssl'<\/span>=&gt; [\n        <span style=\"color: #8b2252;\">'verify_peer'<\/span> =&gt; <span style=\"color: #008b8b;\">false<\/span>,\n        <span style=\"color: #8b2252;\">'verify_peer_name'<\/span> =&gt; <span style=\"color: #008b8b;\">false<\/span>,\n        <span style=\"color: #8b2252;\">'allow_self_signed'<\/span> =&gt; <span style=\"color: #008b8b;\">true<\/span>\n        ]\n    ];\n    }\n\n\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">Host<\/span> = <span style=\"color: #8b2252;\">'mail.example.com'<\/span>;\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">SMTPAuth<\/span> = <span style=\"color: #008b8b;\">true<\/span>;\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">Username<\/span> = <span style=\"color: #8b2252;\">'robot@example.com'<\/span>;\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">Password<\/span> = <span style=\"color: #8b2252;\">'password'<\/span>;\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">SMTPSecure<\/span> = <span style=\"color: #8b2252;\">'tls'<\/span>;\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">Port<\/span> = <span style=\"color: #000000; background-color: #ffffff;\">587<\/span>;\n\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #000000; background-color: #ffffff;\">setFrom<\/span>(<span style=\"color: #8b2252;\">'robot@example.com'<\/span>, <span style=\"color: #8b2252;\">'Name of sender'<\/span>);\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #000000; background-color: #ffffff;\">addAddress<\/span>(<span style=\"color: #8b2252;\">'joe@example.com'<\/span>, <span style=\"color: #8b2252;\">'Name of recipient'<\/span>);\n\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #000000; background-color: #ffffff;\">isHTML<\/span>(<span style=\"color: #008b8b;\">true<\/span>);\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">Subject<\/span> = <span style=\"color: #8b2252;\">'PHPMailer Test'<\/span>;\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">Body<\/span> = <span style=\"color: #8b2252;\">'This is a &lt;b&gt;SAMPLE&lt;b&gt; email sent through &lt;b&gt;PHPMailer&lt;b&gt;'<\/span>;\n\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #000000; background-color: #ffffff;\">send<\/span>();\n    $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #000000; background-color: #ffffff;\">ClearAllRecipients<\/span>();\n    <span style=\"color: #a020f0;\">echo<\/span> <span style=\"color: #8b2252;\">\"MAIL HAS BEEN SENT SUCCESSFULLY\"<\/span>;\n\n} <span style=\"color: #a020f0;\">catch<\/span> (<span style=\"color: #228b22;\">Exception<\/span> $<span style=\"color: #a0522d;\">e<\/span>) {\n    <span style=\"color: #a020f0;\">echo<\/span> <span style=\"color: #8b2252;\">\"EMAIL SENDING FAILED. INFO: \"<\/span> . $<span style=\"color: #a0522d;\">mailer<\/span>-&gt;<span style=\"color: #a0522d;\">ErrorInfo<\/span>;\n}\n?&gt;\n<\/pre>\n\n\n\n<p>Source: <a href=\"https:\/\/www.myphpnotes.com\/post\/phpmailer-complete-tutorial-with-debugging\">MyPHPnotes<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A note about the <code>?&gt;<\/code> tag <\/h2>\n\n\n\n<p>In PHP, the <code>?&gt;<\/code> tag at the end of a file is optional and can be omitted. The <code>?&gt;<\/code> tag denotes the end of the PHP code block and signifies that the parser should switch back to HTML mode. Including the <code>?&gt;<\/code> tag is necessary only when there is additional non-PHP code or HTML following the PHP block.<\/p>\n\n\n\n<p>Here are a few scenarios to help you understand when to include or exclude the <code>?&gt;<\/code> tag:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pure PHP code<\/h3>\n\n\n\n<p>If your file contains only PHP code and does not include any HTML or non-PHP code after the closing tag, it is recommended to exclude the <code>?&gt;<\/code> tag. Omitting it helps to avoid any accidental whitespace or line breaks after the closing tag, which could unintentionally be sent to the browser.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n\/\/ PHP code here\n\/\/ No closing tag needed\n<\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Mix of PHP and HTML code<\/h3>\n\n\n\n<p>When your file contains both PHP and HTML code, it is generally best to exclude the <code>?&gt;<\/code> tag at the end of the PHP sections. This prevents any accidental output of whitespace or line breaks to the browser.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n\/\/ PHP code here\n?&gt;\n&lt;html&gt;\n&lt;!-- HTML code here --&gt;\n&lt;\/html&gt;\n&lt;?php\n\/\/ More PHP code here\n<\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">PHP code followed by non-PHP code<\/h3>\n\n\n\n<p>If your PHP code is followed by non-PHP code, such as JavaScript or plain text, you should include the <code>?&gt;<\/code> tag after the PHP code block and before the non-PHP code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n\/\/ PHP code here\n?&gt;\n&lt;script&gt;\n\/\/ JavaScript code here\n&lt;\/script&gt;\n&lt;?php\n\/\/ More PHP code here\n\n<\/pre>\n\n\n\n<p>Remember, the inclusion or exclusion of the <code>?&gt;<\/code> tag is a matter of preference and coding style. However, it is important to maintain consistency throughout your codebase to ensure readability and minimize any potential issues.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\">\n\n\n\n<p>Well done! You\u2019ve completed this tutorial. Now, if you have filled in all the correct data, you should be able to run this script in your browser and send mail to the recipient. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHPMailer is a highly popular, actively developed email-sending library for PHP hosting. And it&#8217;s open source. Below, we&#8217;ll give you a quick and easy example of a working script you can use in your local development environment or live on your InMotion Hosting server. For more information about PHPMailer, or to contribute, check out the<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\"> Read More ><\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4288],"tags":[],"class_list":["post-676","post","type-post","status-publish","format-standard","hentry","category-website"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using PHPMailer to Send Mail through PHP | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Want to use phpMailer to send email from your website? Learn how to do that right here!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using PHPMailer to Send Mail through PHP | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Want to use phpMailer to send email from your website? Learn how to do that right here!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2011-08-26T13:40:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-31T16:47:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png\" \/>\n<meta name=\"author\" content=\"Christopher Maiorana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christopher Maiorana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\"},\"author\":{\"name\":\"Christopher Maiorana\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f\"},\"headline\":\"Using PHPMailer to Send Mail through PHP\",\"datePublished\":\"2011-08-26T13:40:12+00:00\",\"dateModified\":\"2025-03-31T16:47:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\"},\"wordCount\":562,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png\",\"articleSection\":[\"Website\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\",\"name\":\"Using PHPMailer to Send Mail through PHP | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png\",\"datePublished\":\"2011-08-26T13:40:12+00:00\",\"dateModified\":\"2025-03-31T16:47:48+00:00\",\"description\":\"Want to use phpMailer to send email from your website? Learn how to do that right here!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP.png\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP.png\",\"width\":1200,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using PHPMailer to Send Mail through PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f\",\"name\":\"Christopher Maiorana\",\"description\":\"Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/chris-m-4623144b\/\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/christopherm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using PHPMailer to Send Mail through PHP | InMotion Hosting","description":"Want to use phpMailer to send email from your website? Learn how to do that right here!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/","og_locale":"en_US","og_type":"article","og_title":"Using PHPMailer to Send Mail through PHP | InMotion Hosting","og_description":"Want to use phpMailer to send email from your website? Learn how to do that right here!","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2011-08-26T13:40:12+00:00","article_modified_time":"2025-03-31T16:47:48+00:00","og_image":[{"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png","type":"","width":"","height":""}],"author":"Christopher Maiorana","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Christopher Maiorana","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/"},"author":{"name":"Christopher Maiorana","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f"},"headline":"Using PHPMailer to Send Mail through PHP","datePublished":"2011-08-26T13:40:12+00:00","dateModified":"2025-03-31T16:47:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/"},"wordCount":562,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png","articleSection":["Website"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/","name":"Using PHPMailer to Send Mail through PHP | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP-1024x538.png","datePublished":"2011-08-26T13:40:12+00:00","dateModified":"2025-03-31T16:47:48+00:00","description":"Want to use phpMailer to send email from your website? Learn how to do that right here!","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP.png","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2022\/02\/PHPMailer-Send-Email-From-PHP.png","width":1200,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/using-phpmailer-to-send-mail-through-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Using PHPMailer to Send Mail through PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f","name":"Christopher Maiorana","description":"Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.","sameAs":["https:\/\/www.linkedin.com\/in\/chris-m-4623144b\/"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/christopherm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4288,"name":"Website","slug":"website","link":"https:\/\/www.inmotionhosting.com\/support\/website\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=676"}],"version-history":[{"count":18,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/676\/revisions"}],"predecessor-version":[{"id":129858,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/676\/revisions\/129858"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}