{"id":4657,"date":"2021-05-31T13:58:38","date_gmt":"2021-05-31T13:58:38","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=4657"},"modified":"2021-05-31T13:58:38","modified_gmt":"2021-05-31T13:58:38","slug":"laravel-send-email-with-smtp-server-phpmailer","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/","title":{"rendered":"Send Email via SMTP Server in Laravel using PHPMailer"},"content":{"rendered":"<p>Generally, we used the default mail() function to send emails in the PHP-based web application. But, the <b>PHP mail()<\/b> function sometimes fails to deliver email or deliver mail to the spam folder. Due to this, the SMTP server is always recommended to send email from the script in the web application. The PHPMailer library can be used to <a href=\"https:\/\/www.codexworld.com\/send-html-email-php-gmail-smtp-phpmailer\/\">send email with an SMTP server using PHP<\/a>. You can integrate the PHPMailer library to send email from any PHP frameworks (CodeIgniter, Laravel, Lumen, etc.).<\/p>\n<p>The PHPMailer library provides an easy way to send email via an SMTP server using PHP. If your application built with Laravel, the PHPMailer library can be used to send an email with SMTP server. In this tutorial, we will show you how to <b>send email via SMTP server in Laravel<\/b> using PHPMailer.<\/p>\n<h2>Send email via SMTP server in Laravel<\/h2>\n<p>Run the following command to install PHPMailer via Composer in your Laravel application.<\/p>\n<pre>composer require phpmailer\/phpmailer<\/pre>\n<p>Load the PHPMailer and Exception classes.<\/p>\n<pre><span style=\"color: #007700\">use&nbsp;<\/span><span style=\"color: #0000BB\">PHPMailer<\/span><span style=\"color: #007700\">\\<\/span><span style=\"color: #0000BB\">PHPMailer<\/span><span style=\"color: #007700\">\\<\/span><span style=\"color: #0000BB\">PHPMailer<\/span><span style=\"color: #007700\">;&nbsp; <br \/>use&nbsp;<\/span><span style=\"color: #0000BB\">PHPMailer<\/span><span style=\"color: #007700\">\\<\/span><span style=\"color: #0000BB\">PHPMailer<\/span><span style=\"color: #007700\">\\<\/span><span style=\"color: #0000BB\">Exception<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<p>Initialize the PHPMailer class, configure SMTP and email.<\/p>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;an&nbsp;instance&nbsp;of&nbsp;PHPMailer&nbsp;class&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">PHPMailer<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;SMTP&nbsp;configurations <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">isSMTP<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Host&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'smtp.example.com'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">SMTPAuth&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Username&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'user@example.com'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Password&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'******'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">SMTPSecure&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'tls'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">587<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Sender&nbsp;info&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">setFrom<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'sender@example.com'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'SenderName'<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Add&nbsp;a&nbsp;recipient&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">addAddress<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'recipient@example.com'<\/span><span style=\"color: #007700\">);&nbsp; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Add&nbsp;cc&nbsp;or&nbsp;bcc&nbsp;&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">addCC<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'cc@example.com'<\/span><span style=\"color: #007700\">);&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">addBCC<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'bcc@example.com'<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Email&nbsp;subject&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Subject&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Send&nbsp;Email&nbsp;via&nbsp;SMTP&nbsp;in&nbsp;Laravel'<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;email&nbsp;format&nbsp;to&nbsp;HTML&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">isHTML<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Email&nbsp;body&nbsp;content&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mailContent&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;h2&gt;Send&nbsp;HTML&nbsp;Email&nbsp;using&nbsp;SMTP&nbsp;Server&nbsp;in&nbsp;Laravel&lt;\/h2&gt;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;It&nbsp;is&nbsp;a&nbsp;test&nbsp;email&nbsp;by&nbsp;CodexWorld,&nbsp;sent&nbsp;via&nbsp;SMTP&nbsp;server&nbsp;with&nbsp;PHPMailer&nbsp;in&nbsp;Laravel.&lt;\/p&gt;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;Read&nbsp;the&nbsp;tutorial&nbsp;and&nbsp;download&nbsp;this&nbsp;script&nbsp;from&nbsp;&lt;a&nbsp;href=\"https:\/\/www.codexworld.com\/\"&gt;CodexWorld&lt;\/a&gt;.&lt;\/p&gt;'<\/span><span style=\"color: #007700\">;&nbsp; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Body&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$mailContent<\/span><span style=\"color: #007700\">;&nbsp; <br \/>&nbsp; <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Send&nbsp;email&nbsp; <br \/><\/span><span style=\"color: #007700\">if(!<\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">send<\/span><span style=\"color: #007700\">()){&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Message&nbsp;could&nbsp;not&nbsp;be&nbsp;sent.&nbsp;Mailer&nbsp;Error:&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ErrorInfo<\/span><span style=\"color: #007700\">;&nbsp; <br \/>}else{&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Message&nbsp;has&nbsp;been&nbsp;sent.'<\/span><span style=\"color: #007700\">;&nbsp; <br \/>}<\/span><\/pre>\n<p>Send email via Gmail SMTP server in Laravel<br \/>\nTo use Gmail SMTP for sending emails in Laravel, some settings need to be changed in the Google account. Follow the below steps to use Gmail SMTP with the PHPMailer library in Laravel.<\/p>\n<ul class=\"step_list\">\n<li>Login to your Google account. Go to the <a href=\"https:\/\/myaccount.google.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">My Account page<\/a>.<\/li>\n<li>Navigate to the <b>Security<\/b> page and scroll down to the <b>Signing in to Google<\/b> section \u00bb Turn <b>Off<\/b> the 2-Step Verification<\/li>\n<p>.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/google-account-security-2-step-verification-gmail-smtp-codexworld-1024x378.png\" alt=\"google-account-security-2-step-verification-gmail-smtp-codexworld\" width=\"960\" height=\"354\"><\/div>\n<li>Scroll down the <b>Less secure app access<\/b> section and turn <b>On<\/b> Less secure app access.\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/google-account-security-less-secure-app-access-gmail-smtp-codexworld-1024x333.png\" alt=\"google-account-security-less-secure-app-access-gmail-smtp-codexworld\" width=\"960\" height=\"312\"><\/div>\n<\/li>\n<\/ul>\n<p>You are done! Now you can use Gmail SMTP to send emails from the Laravel application.<\/p>\n<p>Specify your Gmail account credentials (email address and password), SMTP host, and port to send email using Gmail SMTP in Laravel.<\/p>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;SMTP&nbsp;configuration <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">isSMTP<\/span><span style=\"color: #007700\">(); <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Host&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'smtp.gmail.com'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">SMTPAuth&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Username&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'codexworld@gmail.com'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Password&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'******'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">SMTPSecure&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'tls'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$mail<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">Port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">587<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<h2>Conclusion<\/h2>\n<p>This example code helps you to <b>send text or HTML email from Laravel<\/b> application using Laravel Mail service with SMTP server. Not only Laravel but this code can be used to send email from Lumen also. There are various configurations are available in PHPMailer to customize the email functionality as per your needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generally, we used the default mail() function to send emails in the PHP-based web application. But, the PHP mail() function sometimes fails to deliver email or deliver mail to the spam folder. Due to this, <\/p>\n","protected":false},"author":1,"featured_media":4659,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[272],"tags":[23,271,147,276],"class_list":["post-4657","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-email","tag-laravel","tag-phpmailer","tag-smtp","cat-272-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Send Email via SMTP Server in Laravel using PHPMailer - CodexWorld<\/title>\n<meta name=\"description\" content=\"Send email in Laravel - Example code to send email via SMTP server in Laravel. Use PHPMailer library to send HTML email from Laravel with Gmail SMTP server.\" \/>\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.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Send Email via SMTP Server in Laravel using PHPMailer - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Send email in Laravel - Example code to send email via SMTP server in Laravel. Use PHPMailer library to send HTML email from Laravel with Gmail SMTP server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-31T13:58:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2021\/05\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Send Email via SMTP Server in Laravel using PHPMailer\",\"datePublished\":\"2021-05-31T13:58:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/\"},\"wordCount\":357,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png\",\"keywords\":[\"Email\",\"Laravel\",\"PHPMailer\",\"SMTP\"],\"articleSection\":[\"Laravel\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/\",\"name\":\"Send Email via SMTP Server in Laravel using PHPMailer - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png\",\"datePublished\":\"2021-05-31T13:58:38+00:00\",\"description\":\"Send email in Laravel - Example code to send email via SMTP server in Laravel. Use PHPMailer library to send HTML email from Laravel with Gmail SMTP server.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"laravel-send-email-with-smtp-server-phpmailer-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/laravel-send-email-with-smtp-server-phpmailer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Send Email via SMTP Server in Laravel using PHPMailer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Send Email via SMTP Server in Laravel using PHPMailer - CodexWorld","description":"Send email in Laravel - Example code to send email via SMTP server in Laravel. Use PHPMailer library to send HTML email from Laravel with Gmail SMTP server.","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.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/","og_locale":"en_US","og_type":"article","og_title":"Send Email via SMTP Server in Laravel using PHPMailer - CodexWorld","og_description":"Send email in Laravel - Example code to send email via SMTP server in Laravel. Use PHPMailer library to send HTML email from Laravel with Gmail SMTP server.","og_url":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2021-05-31T13:58:38+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2021\/05\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Send Email via SMTP Server in Laravel using PHPMailer","datePublished":"2021-05-31T13:58:38+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/"},"wordCount":357,"commentCount":0,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2021\/05\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png","keywords":["Email","Laravel","PHPMailer","SMTP"],"articleSection":["Laravel"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/","url":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/","name":"Send Email via SMTP Server in Laravel using PHPMailer - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2021\/05\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png","datePublished":"2021-05-31T13:58:38+00:00","description":"Send email in Laravel - Example code to send email via SMTP server in Laravel. Use PHPMailer library to send HTML email from Laravel with Gmail SMTP server.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2021\/05\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2021\/05\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png","width":1366,"height":768,"caption":"laravel-send-email-with-smtp-server-phpmailer-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/laravel-send-email-with-smtp-server-phpmailer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Send Email via SMTP Server in Laravel using PHPMailer"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2021\/05\/laravel-send-email-with-smtp-server-phpmailer-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-1d7","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=4657"}],"version-history":[{"count":2,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4657\/revisions"}],"predecessor-version":[{"id":4660,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/4657\/revisions\/4660"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/4659"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=4657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=4657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=4657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}