{"id":2492,"date":"2017-05-31T16:15:27","date_gmt":"2017-05-31T16:15:27","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=2492"},"modified":"2017-05-31T16:19:08","modified_gmt":"2017-05-31T16:19:08","slug":"codeigniter-send-email-gmail-smtp-server","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/","title":{"rendered":"Sending Email via SMTP Server in CodeIgniter"},"content":{"rendered":"<p>Using SMTP server is always a good idea to send email from the script. Sometimes PHP <code>mail()<\/code> function fails to send email to the recipient or deliver email to the spam folder. To avoid this issue SMTP is an effective way to send an email. <b>CodeIgniter Email Class<\/b> provides an easy way to send email from the PHP script. Also, you can send email via SMTP server using CodeIgniter Email library.<\/p>\n<p>In this tutorial, we will show how you can <b>send HTML email via SMTP server in CodeIgniter<\/b> application. The CodeIgniter email library will be used to send email using SMTP server.<\/p>\n<h2>Send email via SMTP server in CodeIgniter<\/h2>\n<p>At first include the CodeIgniter email library. Now specify the SMTP host (<code>smtp_host<\/code>), port (<code>smtp_port<\/code>), email (<code>smtp_user<\/code>), and password (<code>smtp_pass<\/code>) in SMTP configuration (<code>$config<\/code>) as per your SMTP server.<\/p>\n<pre><span style=\"color: #FF8000\">\/\/Load&nbsp;email&nbsp;library<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">library<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'email'<\/span><span style=\"color: #007700\">);<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/SMTP&nbsp;&amp;&nbsp;mail&nbsp;configuration<br \/><\/span><span style=\"color: #0000BB\">$config&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'protocol'&nbsp;<\/span><span style=\"color: #007700\">&nbsp;=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_host'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'ssl:\/\/smtp.example.com'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_port'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">465<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_user'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'email@example.com'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_pass'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'email_password'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'mailtype'&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'html'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'charset'&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'utf-8'<br \/><\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">initialize<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">set_mailtype<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"html\"<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">set_newline<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"\\r\\n\"<\/span><span style=\"color: #007700\">);<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/Email&nbsp;content<br \/><\/span><span style=\"color: #0000BB\">$htmlContent&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;h1&gt;Sending&nbsp;email&nbsp;via&nbsp;SMTP&nbsp;server&lt;\/h1&gt;'<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$htmlContent&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;p&gt;This&nbsp;email&nbsp;has&nbsp;sent&nbsp;via&nbsp;SMTP&nbsp;server&nbsp;from&nbsp;CodeIgniter&nbsp;application.&lt;\/p&gt;'<\/span><span style=\"color: #007700\">;<br \/><br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">to<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'recipient@example.com'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">from<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'sender@example.com'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'MyWebsite'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">subject<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'How&nbsp;to&nbsp;send&nbsp;email&nbsp;via&nbsp;SMTP&nbsp;server&nbsp;in&nbsp;CodeIgniter'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">message<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$htmlContent<\/span><span style=\"color: #007700\">);<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/Send&nbsp;email<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">send<\/span><span style=\"color: #007700\">();<\/span><\/pre>\n<h2>Send email via Gmail SMTP server in CodeIgniter<\/h2>\n<p>To use Gmail SMTP for sending email in CodeIgniter, you need to make some changes in Google account settings. Follow the below steps to use <b>Gmail SMTP in CodeIgniter<\/b> email library.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Login to your Google account.<\/li>\n<li>Go to the <a href=\"https:\/\/myaccount.google.com\" target=\"_blank\">My Account<\/a> page. Click the <b>Signing in to Google<\/b> link from <b>Sign-in &amp; security<\/b> section.\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-account-settings-codexworld.png\" alt=\"send-email-php-gmail-smtp-account-settings-codexworld\" width=\"824\" height=\"478\" class=\"alignnone size-full wp-image-2321\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-account-settings-codexworld.png 824w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-account-settings-codexworld-300x174.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-account-settings-codexworld-768x446.png 768w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-account-settings-codexworld-200x116.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-account-settings-codexworld-346x201.png 346w\" sizes=\"auto, (max-width: 824px) 100vw, 824px\" \/><\/div>\n<\/li>\n<li>Scroll down the <b>Password &amp; sign-in method<\/b> section and turn Off the <b>2-Step Verification<\/b>.\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-off-2-step-verification-codexworld.png\" alt=\"send-email-php-gmail-smtp-off-2-step-verification-codexworld\" width=\"630\" height=\"386\" class=\"alignnone size-full wp-image-2322\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-off-2-step-verification-codexworld.png 630w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-off-2-step-verification-codexworld-300x184.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-off-2-step-verification-codexworld-200x123.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-off-2-step-verification-codexworld-346x212.png 346w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><\/div>\n<\/li>\n<li>Scroll down the <b>Connected apps &amp; sites<\/b> section and turn On <b>Allow less secure apps<\/b>.\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-allow-less-secure-apps-codexworld.png\" alt=\"send-email-php-gmail-smtp-allow-less-secure-apps-codexworld\" width=\"644\" height=\"229\" class=\"alignnone size-full wp-image-2323\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-allow-less-secure-apps-codexworld.png 644w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-allow-less-secure-apps-codexworld-300x107.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-allow-less-secure-apps-codexworld-200x71.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/04\/send-email-php-gmail-smtp-allow-less-secure-apps-codexworld-346x123.png 346w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/div>\n<\/li>\n<\/ul>\n<p>Now your Gmail account is ready to use in CodeIgniter email library as an SMTP server.<\/p>\n<p>The following example code help to send HTML email in CodeIgniter using your Gmail account. You only need to specify your Gmail email address (smtp_user) and password (smtp_pass).<\/p>\n<pre><span style=\"color: #FF8000\">\/\/Load&nbsp;email&nbsp;library<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">library<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'email'<\/span><span style=\"color: #007700\">);<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/SMTP&nbsp;&amp;&nbsp;mail&nbsp;configuration<br \/><\/span><span style=\"color: #0000BB\">$config&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'protocol'&nbsp;<\/span><span style=\"color: #007700\">&nbsp;=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_host'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'ssl:\/\/smtp.googlemail.com'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_port'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">465<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_user'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'user@gmail.com'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'smtp_pass'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'gmail_password'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'mailtype'&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'html'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'charset'&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'utf-8'<br \/><\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">initialize<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">set_mailtype<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"html\"<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">set_newline<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"\\r\\n\"<\/span><span style=\"color: #007700\">);<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/Email&nbsp;content<br \/><\/span><span style=\"color: #0000BB\">$htmlContent&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;h1&gt;Sending&nbsp;email&nbsp;via&nbsp;SMTP&nbsp;server&lt;\/h1&gt;'<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$htmlContent&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;p&gt;This&nbsp;email&nbsp;has&nbsp;sent&nbsp;via&nbsp;SMTP&nbsp;server&nbsp;from&nbsp;CodeIgniter&nbsp;application.&lt;\/p&gt;'<\/span><span style=\"color: #007700\">;<br \/><br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">to<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'recipient@example.com'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">from<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'sender@example.com'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'MyWebsite'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">subject<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'How&nbsp;to&nbsp;send&nbsp;email&nbsp;via&nbsp;SMTP&nbsp;server&nbsp;in&nbsp;CodeIgniter'<\/span><span style=\"color: #007700\">);<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">message<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$htmlContent<\/span><span style=\"color: #007700\">);<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/Send&nbsp;email<br \/><\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">email<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">send<\/span><span style=\"color: #007700\">();<\/span>\r\n<\/span><\/pre>\n<p>If you notice that the emails are sent to the spam folder, use Encrypt Class in CodeIgniter to solve this issue in Gmail. You need to load the CodeIgniter Encrypt library before sending the email. It will encrypt your email and help to avoid the spamming issue in Gmail.<\/p>\n<pre><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">library<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'encrypt'<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using SMTP server is always a good idea to send email from the script. Sometimes PHP mail() function fails to send email to the recipient or deliver email to the spam folder. To avoid this <\/p>\n","protected":false},"author":1,"featured_media":2494,"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":[8],"tags":[55,23,24,276],"class_list":["post-2492","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codeigniter","tag-codeigniter","tag-email","tag-html-email","tag-smtp","cat-8-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>Sending Email via SMTP Server in CodeIgniter - CodexWorld<\/title>\n<meta name=\"description\" content=\"CodeIgniter email with SMTP server - Learn how to send email via SMTP server in CodeIgniter. Example code to send HTML email using Gmail SMTP in CodeIgniter.\" \/>\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\/codeigniter-send-email-gmail-smtp-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sending Email via SMTP Server in CodeIgniter - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"CodeIgniter email with SMTP server - Learn how to send email via SMTP server in CodeIgniter. Example code to send HTML email using Gmail SMTP in CodeIgniter.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/\" \/>\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=\"2017-05-31T16:15:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-05-31T16:19:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/codeigniter-send-email-via-gmail-smtp-server-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\\\/codeigniter-send-email-gmail-smtp-server\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Sending Email via SMTP Server in CodeIgniter\",\"datePublished\":\"2017-05-31T16:15:27+00:00\",\"dateModified\":\"2017-05-31T16:19:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/\"},\"wordCount\":325,\"commentCount\":12,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png\",\"keywords\":[\"CodeIgniter\",\"Email\",\"HTML Email\",\"SMTP\"],\"articleSection\":[\"CodeIgniter\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/\",\"name\":\"Sending Email via SMTP Server in CodeIgniter - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png\",\"datePublished\":\"2017-05-31T16:15:27+00:00\",\"dateModified\":\"2017-05-31T16:19:08+00:00\",\"description\":\"CodeIgniter email with SMTP server - Learn how to send email via SMTP server in CodeIgniter. Example code to send HTML email using Gmail SMTP in CodeIgniter.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2017\\\/05\\\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"codeigniter-send-email-via-gmail-smtp-server-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/codeigniter-send-email-gmail-smtp-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sending Email via SMTP Server in CodeIgniter\"}]},{\"@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":"Sending Email via SMTP Server in CodeIgniter - CodexWorld","description":"CodeIgniter email with SMTP server - Learn how to send email via SMTP server in CodeIgniter. Example code to send HTML email using Gmail SMTP in CodeIgniter.","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\/codeigniter-send-email-gmail-smtp-server\/","og_locale":"en_US","og_type":"article","og_title":"Sending Email via SMTP Server in CodeIgniter - CodexWorld","og_description":"CodeIgniter email with SMTP server - Learn how to send email via SMTP server in CodeIgniter. Example code to send HTML email using Gmail SMTP in CodeIgniter.","og_url":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2017-05-31T16:15:27+00:00","article_modified_time":"2017-05-31T16:19:08+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/codeigniter-send-email-via-gmail-smtp-server-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\/codeigniter-send-email-gmail-smtp-server\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Sending Email via SMTP Server in CodeIgniter","datePublished":"2017-05-31T16:15:27+00:00","dateModified":"2017-05-31T16:19:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/"},"wordCount":325,"commentCount":12,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png","keywords":["CodeIgniter","Email","HTML Email","SMTP"],"articleSection":["CodeIgniter"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/","url":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/","name":"Sending Email via SMTP Server in CodeIgniter - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png","datePublished":"2017-05-31T16:15:27+00:00","dateModified":"2017-05-31T16:19:08+00:00","description":"CodeIgniter email with SMTP server - Learn how to send email via SMTP server in CodeIgniter. Example code to send HTML email using Gmail SMTP in CodeIgniter.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2017\/05\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png","width":1366,"height":768,"caption":"codeigniter-send-email-via-gmail-smtp-server-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/codeigniter-send-email-gmail-smtp-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Sending Email via SMTP Server in CodeIgniter"}]},{"@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\/2017\/05\/codeigniter-send-email-via-gmail-smtp-server-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-Ec","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2492","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=2492"}],"version-history":[{"count":3,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2492\/revisions"}],"predecessor-version":[{"id":2498,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/2492\/revisions\/2498"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/2494"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=2492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=2492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=2492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}