{"id":667,"date":"2015-07-10T10:51:47","date_gmt":"2015-07-10T10:51:47","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=667"},"modified":"2022-07-26T06:03:06","modified_gmt":"2022-07-26T06:03:06","slug":"send-beautiful-html-email-using-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/","title":{"rendered":"Send Text and HTML Email using PHP"},"content":{"rendered":"<p>Sending email from the script is a very useful and most used feature for the web application. The email functionality is used for many purposes &#8211; sending a welcome email on account registration, sending newsletter, contact or feedback form, etc. By sending an email from the script, the mail is sent dynamically to the recipient without manual interaction.<\/p>\n<p>If your web application is built with PHP, the email can be sent easily from the script using a predefined function. The <b>PHP mail()<\/b> function is the easiest way to send an email from the code level. You can easily send text and HTML emails using the built-in mail() function in PHP. Generally, the text message is sent via email to the recipient. If you want to send a nice formatted email, HTML content needs to be added to the message body of the email. In this tutorial, we will show you how to <b>send text and HTML emails using PHP<\/b> mail() function.<\/p>\n<h2>Send Text Email with PHP<\/h2>\n<p>The following code sends an email from the script with text message content using PHP.<\/p>\n<p>Use the <b>PHP mail()<\/b> function and pass the required parameters.<\/p>\n<ul class=\"bullet_disk_list\">\n<li><code>to<\/code> &#8211; Recipient email address. <\/li>\n<li><code>subject<\/code> &#8211; Subject of the email.<\/li>\n<li><code>message<\/code> &#8211; Message to be sent.<\/li>\n<li><code>headers<\/code> &#8211; From, Cc, Bcc, Content-type headers.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">$to&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\">$from&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'sender@email.com'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$fromName&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Sender_Name'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #0000BB\">$subject&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"Send&nbsp;Text&nbsp;Email&nbsp;with&nbsp;PHP&nbsp;by&nbsp;CodexWorld\"<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #0000BB\">$message&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"First&nbsp;line&nbsp;of&nbsp;text\\nSecond&nbsp;line&nbsp;of&nbsp;text\"<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Additional&nbsp;headers <br \/><\/span><span style=\"color: #0000BB\">$headers&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'From:&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$fromName<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&lt;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$from<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&gt;'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Send&nbsp;email <br \/><\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">mail<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$to<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$subject<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$message<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$headers<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Email&nbsp;has&nbsp;sent&nbsp;successfully.'<\/span><span style=\"color: #007700\">; <br \/>}else{ <br \/>&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Email&nbsp;sending&nbsp;failed.'<\/span><span style=\"color: #007700\">; <br \/>}<\/span><\/pre>\n<h2>Send HTML email in PHP<\/h2>\n<p>The following code sends an email from the script with HTML message content using PHP.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Use the PHP mail() function and provide the required parameters.\n<ul>\n<li><code>to<\/code> &#8211; Recipient email address. <\/li>\n<li><code>subject<\/code> &#8211; Subject of the email.<\/li>\n<li><code>message<\/code> &#8211; Message to be sent.<\/li>\n<li><code>headers<\/code> &#8211; From, Cc, Bcc, Content-type headers.<\/li>\n<\/ul>\n<\/li>\n<li>The content-type header is mandatory for sending HTML formatted email.<\/li>\n<li>The additional headers are used for adding From, Cc, Bcc, etc.<\/li>\n<li><code>$htmlContent<\/code> variable holds the HTML contents of the email.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">$to&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\">$from&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'sender@example.com'<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$fromName&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'SenderName'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #0000BB\">$subject&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"Send&nbsp;HTML&nbsp;Email&nbsp;in&nbsp;PHP&nbsp;by&nbsp;CodexWorld\"<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #0000BB\">$htmlContent&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">' <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;html&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;head&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;Welcome&nbsp;to&nbsp;CodexWorld&lt;\/title&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/head&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;body&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;h1&gt;Thanks&nbsp;you&nbsp;for&nbsp;joining&nbsp;with&nbsp;us!&lt;\/h1&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;table&nbsp;cellspacing=\"0\"&nbsp;style=\"border:&nbsp;2px&nbsp;dashed&nbsp;#FB4314;&nbsp;width:&nbsp;100%;\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th&gt;Name:&lt;\/th&gt;&lt;td&gt;CodexWorld&lt;\/td&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/tr&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&nbsp;style=\"background-color:&nbsp;#e0e0e0;\"&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th&gt;Email:&lt;\/th&gt;&lt;td&gt;contact@codexworld.com&lt;\/td&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/tr&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;th&gt;Website:&lt;\/th&gt;&lt;td&gt;&lt;a&nbsp;href=\"http:\/\/www.codexworld.com\"&gt;www.codexworld.com&lt;\/a&gt;&lt;\/td&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/tr&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/table&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/body&gt; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/html&gt;'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;content-type&nbsp;header&nbsp;for&nbsp;sending&nbsp;HTML&nbsp;email <br \/><\/span><span style=\"color: #0000BB\">$headers&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"MIME-Version:&nbsp;1.0\"&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\r\\n\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$headers&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"Content-type:text\/html;charset=UTF-8\"&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\r\\n\"<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Additional&nbsp;headers <br \/><\/span><span style=\"color: #0000BB\">$headers&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'From:&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$fromName<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&lt;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$from<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\r\\n\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$headers&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'Cc:&nbsp;welcome@example.com'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\r\\n\"<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$headers&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'Bcc:&nbsp;welcome2@example.com'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\r\\n\"<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Send&nbsp;email <br \/><\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">mail<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$to<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$subject<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$htmlContent<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$headers<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Email&nbsp;has&nbsp;sent&nbsp;successfully.'<\/span><span style=\"color: #007700\">; <br \/>}else{ <br \/>&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'Email&nbsp;sending&nbsp;failed.'<\/span><span style=\"color: #007700\">; <br \/>}<\/span><\/pre>\n<h2>Send Email with HTML Content from File<\/h2>\n<p>If you want to send email with large HTML content, it&#8217;s always a good idea to separate message content in HTML file. This functionality is very useful when you want to use the dynamic email template for sending mail.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Put the HTML content of the message in an HTML file (<code>email_template.html<\/code>).<\/li>\n<li>Use <b>file_get_contents()<\/b> function to retrieve HTML content from the file.<\/li>\n<\/ul>\n<pre><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;HTML&nbsp;contents&nbsp;from&nbsp;file <br \/><\/span><span style=\"color: #0000BB\">$htmlContent&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">file_get_contents<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"email_template.html\"<\/span><span style=\"color: #007700\">);<\/span><\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/create-simple-contact-form-php-send-email\/\">Creating a Simple Contact Form with PHP<\/a><\/span><\/p>\n<h2>Conclusion<\/h2>\n<p>This example script helps you to send HTML email with Cc or Bcc address in PHP. You can use this code to send multiple emails dynamically from the script using PHP. Specify the additional headers to <a href=\"https:\/\/www.codexworld.com\/send-email-with-attachment-php\/\">send email with attachment in PHP<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sending email from the script is a very useful and most used feature for the web application. The email functionality is used for many purposes &#8211; sending a welcome email on account registration, sending newsletter, <\/p>\n","protected":false},"author":1,"featured_media":4087,"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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[23,24,14],"class_list":["post-667","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-email","tag-html-email","tag-php","cat-4-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 Text and HTML Email using PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"Text and HTML email with PHP - Send HTML email in PHP. Use mail() function in PHP to send email from script. Code snippet to send HTML email using PHP.\" \/>\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\/send-beautiful-html-email-using-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Send Text and HTML Email using PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Text and HTML email with PHP - Send HTML email in PHP. Use mail() function in PHP to send email from script. Code snippet to send HTML email using PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/\" \/>\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=\"2015-07-10T10:51:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-26T06:03:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/07\/send-text-html-email-using-php-mail-function-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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Send Text and HTML Email using PHP\",\"datePublished\":\"2015-07-10T10:51:47+00:00\",\"dateModified\":\"2022-07-26T06:03:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/\"},\"wordCount\":417,\"commentCount\":30,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/send-text-html-email-using-php-mail-function-codexworld.png\",\"keywords\":[\"Email\",\"HTML Email\",\"PHP\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/\",\"name\":\"Send Text and HTML Email using PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/send-text-html-email-using-php-mail-function-codexworld.png\",\"datePublished\":\"2015-07-10T10:51:47+00:00\",\"dateModified\":\"2022-07-26T06:03:06+00:00\",\"description\":\"Text and HTML email with PHP - Send HTML email in PHP. Use mail() function in PHP to send email from script. Code snippet to send HTML email using PHP.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/send-text-html-email-using-php-mail-function-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/07\\\/send-text-html-email-using-php-mail-function-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"send-text-html-email-using-php-mail-function-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/send-beautiful-html-email-using-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Send Text and HTML Email using PHP\"}]},{\"@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 Text and HTML Email using PHP - CodexWorld","description":"Text and HTML email with PHP - Send HTML email in PHP. Use mail() function in PHP to send email from script. Code snippet to send HTML email using PHP.","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\/send-beautiful-html-email-using-php\/","og_locale":"en_US","og_type":"article","og_title":"Send Text and HTML Email using PHP - CodexWorld","og_description":"Text and HTML email with PHP - Send HTML email in PHP. Use mail() function in PHP to send email from script. Code snippet to send HTML email using PHP.","og_url":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-07-10T10:51:47+00:00","article_modified_time":"2022-07-26T06:03:06+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/07\/send-text-html-email-using-php-mail-function-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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Send Text and HTML Email using PHP","datePublished":"2015-07-10T10:51:47+00:00","dateModified":"2022-07-26T06:03:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/"},"wordCount":417,"commentCount":30,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/07\/send-text-html-email-using-php-mail-function-codexworld.png","keywords":["Email","HTML Email","PHP"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/","url":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/","name":"Send Text and HTML Email using PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/07\/send-text-html-email-using-php-mail-function-codexworld.png","datePublished":"2015-07-10T10:51:47+00:00","dateModified":"2022-07-26T06:03:06+00:00","description":"Text and HTML email with PHP - Send HTML email in PHP. Use mail() function in PHP to send email from script. Code snippet to send HTML email using PHP.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/07\/send-text-html-email-using-php-mail-function-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/07\/send-text-html-email-using-php-mail-function-codexworld.png","width":1366,"height":768,"caption":"send-text-html-email-using-php-mail-function-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/send-beautiful-html-email-using-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Send Text and HTML Email using PHP"}]},{"@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\/2015\/07\/send-text-html-email-using-php-mail-function-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-aL","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/667","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=667"}],"version-history":[{"count":8,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/667\/revisions"}],"predecessor-version":[{"id":5016,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/667\/revisions\/5016"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/4087"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}