{"id":274,"date":"2018-12-08T16:55:34","date_gmt":"2018-12-08T11:25:34","guid":{"rendered":"https:\/\/mediastroke.com\/blog\/?p=274"},"modified":"2018-12-20T10:00:42","modified_gmt":"2018-12-20T04:30:42","slug":"how-to-send-mail-using-php-mail-configuration","status":"publish","type":"post","link":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/","title":{"rendered":"How to send mail using PHP mail configuration"},"content":{"rendered":"

How to send mail using PHP mail configuration<\/strong><\/h1>\n

Sending mail is an internal part of a business. Nowadays being quick and responsive is very important especially when it comes to giving\u00a0an answer to the customer. Multiple times well-planned communication are deciding factors that users take into consideration while purchasing our product.<\/span><\/p>\n

There are several ways to deliver mail while we are looking into PHP mail. At the very core, you can send an email via PHP by using a library such as PHPMailer<\/b> w<\/span>ith <\/span>SMTP<\/b>. PHPMailer is an effective method to send emails in PHP based environment.<\/span><\/p>\n

1. Gathering details for PHPMailer:-<\/b><\/span><\/h4>\n

To use PHPMailer you need to create an email account. You can do this at Email Account section in cPanel (web hosting panel).<\/span><\/p>\n

\"How<\/a><\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

2. Creating a test file for PHP mail:-<\/b><\/span><\/h4>\n

First of all, we need to create a file for PHP mail. We can place that file in the public_html <\/span>directory. You can reach to this through a file manager. Let’s name the file mail.php.<\/span><\/p>\n

\"How<\/a><\/p>\n

3<\/span>. To understand how PHP file works:-<\/span><\/b><\/span><\/h4>\n

\"How<\/a><\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

 <\/p>\n

Understand <\/span>the importance <\/span>of <\/span>each component:-<\/span><\/b><\/h4>\n\n\n\n<\/colgroup>\n\n\n\n\n\n\n
\n

PHPMailer<\/span><\/p>\n<\/td>\n

\n

This line imports the class library of PHPMailer to a global namespace. While running mail.php file we should include PHPMailer library class file, Without class file, it is not possible to send mail.<\/span><\/p>\n<\/td>\n<\/tr>\n

\n

$mail-><\/span><\/p>\n<\/td>\n

\n

This variable contains vital information about server details, headers message and more. This variable also ensures to the sender about SMTP authentication.<\/p>\n<\/td>\n<\/tr>\n

\n

SMTPAuth= True<\/span><\/p>\n<\/td>\n

\n

When the value is false then it means script can send mail without issue, But if the value is true then it cannot connect to SMTP if you have any issue in your script.<\/p>\n<\/td>\n<\/tr>\n

\n

SMTPSecure= tls<\/span><\/p>\n<\/td>\n

\n

This indicates that mail is secure. We can also use SSL for it.<\/span><\/p>\n<\/td>\n<\/tr>\n

\n

Port<\/span><\/p>\n<\/td>\n

\n

Port number 587 is default mail submission port. When a client is sending mail it gets routed by a proper mail server that’s why we use this port.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

4. Running the PHPMailer script:-<\/b><\/h4>\n

Execute the script by entering YourDomain.com\/testphpmailer.php <\/b>and you will see this kind of message.<\/p>\n

\"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

How to send mail using PHP mail configuration Sending mail is an internal part of a business. Nowadays being quick […]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[21,23,22,20],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-hp-send-email-smtp","tag-php-mail-configuration","tag-php-script-to-send-email","tag-php-send-email"],"yoast_head":"\nHow to send mail using PHP mail configuration -<\/title>\n<meta name=\"description\" content=\"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to send mail using PHP mail configuration\" \/>\n<meta property=\"og:description\" content=\"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/mediastroke\" \/>\n<meta property=\"article:published_time\" content=\"2018-12-08T11:25:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-12-20T04:30:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/How-to-send-mail-using-PHP-mail-configuration.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ashwini Patil\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:description\" content=\"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/How-to-send-mail-using-PHP-mail-configuration-1.png\" \/>\n<meta name=\"twitter:creator\" content=\"@mediastrokehost\" \/>\n<meta name=\"twitter:site\" content=\"@mediastrokehost\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashwini Patil\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/\"},\"author\":{\"name\":\"Ashwini Patil\",\"@id\":\"https:\/\/mediastroke.com\/blog\/#\/schema\/person\/ea5503549640cc33f160904632fde0d3\"},\"headline\":\"How to send mail using PHP mail configuration\",\"datePublished\":\"2018-12-08T11:25:34+00:00\",\"dateModified\":\"2018-12-20T04:30:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/\"},\"wordCount\":366,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1-300x156.png\",\"keywords\":[\"hp send email smtp\",\"php mail configuration\",\"php script to send email\",\"php send email\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/\",\"url\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/\",\"name\":\"How to send mail using PHP mail configuration -\",\"isPartOf\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1-300x156.png\",\"datePublished\":\"2018-12-08T11:25:34+00:00\",\"dateModified\":\"2018-12-20T04:30:42+00:00\",\"description\":\"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.\",\"breadcrumb\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage\",\"url\":\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1.png\",\"contentUrl\":\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1.png\",\"width\":974,\"height\":506},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mediastroke.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to send mail using PHP mail configuration\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mediastroke.com\/blog\/#website\",\"url\":\"https:\/\/mediastroke.com\/blog\/\",\"name\":\"\",\"description\":\"Web Hosting Provider\",\"publisher\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mediastroke.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/mediastroke.com\/blog\/#organization\",\"name\":\"MediaStroke\",\"url\":\"https:\/\/mediastroke.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mediastroke.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2024\/03\/mediastroke-white-logo-blog-50h.png\",\"contentUrl\":\"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2024\/03\/mediastroke-white-logo-blog-50h.png\",\"width\":320,\"height\":50,\"caption\":\"MediaStroke\"},\"image\":{\"@id\":\"https:\/\/mediastroke.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/mediastroke\",\"https:\/\/x.com\/mediastrokehost\",\"https:\/\/www.linkedin.com\/company\/mediastroke-servers\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/mediastroke.com\/blog\/#\/schema\/person\/ea5503549640cc33f160904632fde0d3\",\"name\":\"Ashwini Patil\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mediastroke.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7c6d91fde77af64188e00a7bea44477a42347621e7495fbe45fa3b79bfea7c71?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7c6d91fde77af64188e00a7bea44477a42347621e7495fbe45fa3b79bfea7c71?s=96&d=mm&r=g\",\"caption\":\"Ashwini Patil\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to send mail using PHP mail configuration -","description":"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.","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:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/","og_locale":"en_US","og_type":"article","og_title":"How to send mail using PHP mail configuration","og_description":"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.","og_url":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/","article_publisher":"https:\/\/www.facebook.com\/mediastroke","article_published_time":"2018-12-08T11:25:34+00:00","article_modified_time":"2018-12-20T04:30:42+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/How-to-send-mail-using-PHP-mail-configuration.png","type":"image\/png"}],"author":"Ashwini Patil","twitter_card":"summary_large_image","twitter_description":"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.","twitter_image":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/How-to-send-mail-using-PHP-mail-configuration-1.png","twitter_creator":"@mediastrokehost","twitter_site":"@mediastrokehost","twitter_misc":{"Written by":"Ashwini Patil","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#article","isPartOf":{"@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/"},"author":{"name":"Ashwini Patil","@id":"https:\/\/mediastroke.com\/blog\/#\/schema\/person\/ea5503549640cc33f160904632fde0d3"},"headline":"How to send mail using PHP mail configuration","datePublished":"2018-12-08T11:25:34+00:00","dateModified":"2018-12-20T04:30:42+00:00","mainEntityOfPage":{"@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/"},"wordCount":366,"commentCount":0,"publisher":{"@id":"https:\/\/mediastroke.com\/blog\/#organization"},"image":{"@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage"},"thumbnailUrl":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1-300x156.png","keywords":["hp send email smtp","php mail configuration","php script to send email","php send email"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/","url":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/","name":"How to send mail using PHP mail configuration -","isPartOf":{"@id":"https:\/\/mediastroke.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage"},"image":{"@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage"},"thumbnailUrl":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1-300x156.png","datePublished":"2018-12-08T11:25:34+00:00","dateModified":"2018-12-20T04:30:42+00:00","description":"How to send mail using PHP mail configuration with the help of SMTP and TLS security. It gives information about PHP mailing function using PHPMailer file.","breadcrumb":{"@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#primaryimage","url":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1.png","contentUrl":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-07-13-02-17-1.png","width":974,"height":506},{"@type":"BreadcrumbList","@id":"https:\/\/mediastroke.com\/blog\/how-to-send-mail-using-php-mail-configuration\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mediastroke.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to send mail using PHP mail configuration"}]},{"@type":"WebSite","@id":"https:\/\/mediastroke.com\/blog\/#website","url":"https:\/\/mediastroke.com\/blog\/","name":"","description":"Web Hosting Provider","publisher":{"@id":"https:\/\/mediastroke.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mediastroke.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/mediastroke.com\/blog\/#organization","name":"MediaStroke","url":"https:\/\/mediastroke.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mediastroke.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2024\/03\/mediastroke-white-logo-blog-50h.png","contentUrl":"https:\/\/mediastroke.com\/blog\/wp-content\/uploads\/2024\/03\/mediastroke-white-logo-blog-50h.png","width":320,"height":50,"caption":"MediaStroke"},"image":{"@id":"https:\/\/mediastroke.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/mediastroke","https:\/\/x.com\/mediastrokehost","https:\/\/www.linkedin.com\/company\/mediastroke-servers"]},{"@type":"Person","@id":"https:\/\/mediastroke.com\/blog\/#\/schema\/person\/ea5503549640cc33f160904632fde0d3","name":"Ashwini Patil","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mediastroke.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7c6d91fde77af64188e00a7bea44477a42347621e7495fbe45fa3b79bfea7c71?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7c6d91fde77af64188e00a7bea44477a42347621e7495fbe45fa3b79bfea7c71?s=96&d=mm&r=g","caption":"Ashwini Patil"}}]}},"_links":{"self":[{"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":7,"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":580,"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/posts\/274\/revisions\/580"}],"wp:attachment":[{"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/media?parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/categories?post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mediastroke.com\/blog\/wp-json\/wp\/v2\/tags?post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}