{"id":5889,"date":"2019-10-11T09:41:00","date_gmt":"2019-10-11T09:41:00","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/?p=5889"},"modified":"2025-05-22T15:37:05","modified_gmt":"2025-05-22T10:07:05","slug":"send-mail-from-localhost-xampp-using-gmail","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/send-mail-from-localhost-xampp-using-gmail\/","title":{"rendered":"How to Send Mail from Localhost XAMPP Using Gmail"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">XAMPP&nbsp;is Cross-Platform (X), Apache (A), MariaDB (M), PHP (P) and Perl (P). It is for developers to create a local webserver for testing or deployment purposes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a part of testing, developers need to send emails that are always going to be there when it comes to online businesses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To send mail from localhost XAMPP using Gmail, configure XAMPP after installing it. Follow the below steps for the same.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Send Mail From Localhost XAMPP Using Gmail:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. Open XAMPP Installation Directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Go to C:\\xampp\\php and open the php.ini file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. Find [mail function] by pressing ctrl + f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4. Search and pass the following values:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SMTP=smtp.gmail.com\nsmtp_port=587\nsendmail_from = YourGmailId@gmail.com\nsendmail_path = \"\\\"C:\\xampp\\sendmail\\sendmail.exe\\\" -t\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. Now, go to C:\\xampp\\sendmail and open sendmail.ini file.<br>6. Find [sendmail] by pressing ctrl + f.<br>7. Search and pass the following values<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">smtp_server=smtp.gmail.com\nsmtp_port=587\nerror_logfile=error.log\ndebug_logfile=debug.log\nauth_username=YourGmailId@gmail.com\nauth_password=Your-Gmail-Password\nforce_sender=YourGmailId@gmail.com(optional)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Script To Send Mail:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n$to_email = \"receipient@gmail.com\";\n$subject = \"Simple Email Test via PHP\";\n$body = \"Hi,nn This is test email send by PHP Script\";\n$headers = \"From: sender\\'s email\";\n\nif (mail($to_email, $subject, $body, $headers)) {\n    echo \"Email successfully sent to $to_email...\";\n} else {\n    echo \"Email sending failed...\";\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Hope this guide will be helpful!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Please configure \u201cLess secure apps\u201d settings as shown at <a href=\"https:\/\/support.google.com\/cloudidentity\/answer\/6260879\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/support.google.com\/cloudidentity\/answer\/6260879<\/a> for proper working.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, if you are still facing issues, the reason can be one of the below:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. The mails are being sent late<br>2. The mail is not configured properly<br>3. The port is blocked<br>4. Gmail does not have required permissions<br>5. Password is wrong<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the solution via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>XAMPP&nbsp;is Cross-Platform (X), Apache (A), MariaDB (M), PHP (P) and Perl (P). It is for developers to create a local webserver for testing or deployment&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[78],"tags":[],"class_list":["post-5889","post","type-post","status-publish","format-standard","hentry","category-digital-marketing"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/5889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=5889"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/5889\/revisions"}],"predecessor-version":[{"id":15229,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/5889\/revisions\/15229"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=5889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=5889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=5889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}