{"id":1525,"date":"2017-05-24T17:21:16","date_gmt":"2017-05-24T11:51:16","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1525"},"modified":"2017-05-26T07:50:25","modified_gmt":"2017-05-26T02:20:25","slug":"send-email-using-html-templates-codeigniter","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/send-email-using-html-templates-codeigniter\/","title":{"rendered":"How to send email using HTML templates in Codeigniter"},"content":{"rendered":"<p style=\"text-align: left;\"><strong>Date Posted:24-05-2017<\/strong><\/p>\n<p style=\"text-align: left;\">In this post we will explain how to send email using HTML templates in Codeigniter<\/p>\n<h2 style=\"text-align: left;\">How to send email using HTML templates in Codeigniter<\/h2>\n<p>Step 1: Create HTML file with suits to your template.<\/p>\n<p><strong>Path : \/application\/views\/emails\/test-email.php<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"enlighter\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"utf-8\" \/&gt;\r\n    &lt;title&gt;Codeigniter mail templates&lt;\/title&gt;\r\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;p style=\"Margin-top: 0;color: #565656;font-family: Georgia,serif;font-size: 16px;line-height: 25px;Margin-bottom: 25px\"&gt;Hey\r\n        &lt;?php echo $userName;?&gt;,&lt;\/p&gt;\r\n    &lt;p style=\"Margin-top: 0;color: #565656;font-family: Georgia,serif;font-size: 16px;line-height: 25px;Margin-bottom: 25px\"&gt; This is mail demo of How to send email using HTML templates in Codeigniter &lt;\/p&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Step 2: Create new Controller name as sendmails.php,Add method to sendmails.php<\/p>\n<p><strong>Path : \/application\/controllers\/sendmails.php<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r\n\r\nclass Sendmails extends CI_Controller {\r\n\r\n    public function htmlmail(){\r\n    \t$userEmail='email@domain.com'\r\n        $subject='Test'\r\n        $config = Array(       \r\n            'mailtype' =&gt; 'html',\r\n             'charset' =&gt; 'utf-8',\r\n             'priority' =&gt; '1'\r\n        );\r\n        $this-&gt;load-&gt;library('email', $config);\r\n    $this-&gt;email-&gt;set_newline(\"\\r\\n\");\r\n   \r\n        $this-&gt;email-&gt;from('your mail id', 'Pheonix solutions');\r\n        $data = array(\r\n             'userName'=&gt; 'Pheonix solutions'\r\n                 );\r\n        $this-&gt;email-&gt;to($userEmail);  \/\/ replace it with receiver mail id\r\n    $this-&gt;email-&gt;subject($subject); \/\/ replace it with relevant subject\r\n   \r\n        $body = $this-&gt;load-&gt;view('emails\/test-email.php',$data,TRUE);\r\n    $this-&gt;email-&gt;message($body);  \r\n        $this-&gt;email-&gt;send();\r\n    }\r\n       \r\n}\r\n\r\n?&gt;<\/pre>\n<p>Step 3: Call the controller method in as per your requirement.<\/p>\n<p>http:\/\/[domain name]\/Sendmails\/htmlmail<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Date Posted:24-05-2017 In this post we will explain how to send email using HTML templates in Codeigniter How to send [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[341,273],"class_list":["post-1525","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-codeigniter","tag-php","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-oB","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1525"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1525\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}