{"id":594,"date":"2017-06-02T21:37:30","date_gmt":"2017-06-02T18:37:30","guid":{"rendered":"http:\/\/leonidassavvides.com\/blog\/?p=594"},"modified":"2017-06-02T21:37:30","modified_gmt":"2017-06-02T18:37:30","slug":"how-to-configure-xampp-to-send-mail-from-localhost","status":"publish","type":"post","link":"https:\/\/www.leonidassavvides.com\/blog\/2017\/06\/how-to-configure-xampp-to-send-mail-from-localhost\/","title":{"rendered":"How to configure XAMPP to send mail from localhost?"},"content":{"rendered":"<div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" ><\/div><h1 style=\"text-align: center;\">How to configure XAMPP to send mail from localhost?<\/h1>\n<p>&nbsp;<\/p>\n<p>You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP. So if you are using XAMPP then you can easily send mail from localhost.<\/p>\n<p>for example you can configure C:\\xampp\\php\\php.ini and c:\\xampp\\sendmail\\sendmail.ini for gmail to send mail.<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>STEPS<\/strong><\/h2>\n<p>1<\/p>\n<p>in C:\\xampp\\php\\php.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.<br \/>\n2<\/p>\n<p>in php.ini file find [mail function] and change<\/p>\n<p>SMTP=smtp.gmail.com<br \/>\nsmtp_port=587<br \/>\nsendmail_from = my-gmail-id@gmail.com<br \/>\nsendmail_path = &#8220;\\&#8221;C:\\xampp\\sendmail\\sendmail.exe\\&#8221; -t&#8221;<br \/>\n3<\/p>\n<p>Now Open C:\\xampp\\sendmail\\sendmail.ini. Replace all the existing code in sendmail.ini with following code<\/p>\n<p>[sendmail]<\/p>\n<p>smtp_server=smtp.gmail.com<br \/>\nsmtp_port=587<br \/>\nerror_logfile=error.log<br \/>\ndebug_logfile=debug.log<br \/>\nauth_username=my-gmail-id@gmail.com<br \/>\nauth_password=my-gmail-password<br \/>\nforce_sender=my-gmail-id@gmail.com<br \/>\n4<\/p>\n<p>ESPECIALLY For gmail please check https:\/\/support.google.com\/accounts\/answer\/6010255 to allow access from less secure apps<\/p>\n<p>SO AS GMAIL TO WORK IN THIS CASE&#8230; OTHER THAN GMAIL MAY OR MAY NOT HAVE [SIMILAR] SECURITY NEEDED SETUP.<br \/>\n5<br \/>\nNow you have done!! create php file with mail function and send mail from localhost.<\/p>\n<p>PS: don&#8217;t forgot to replace my-gmail-id and my-gmail-password in above code. Also, don&#8217;t forget to remove duplicate keys if you copied settings from above.<br \/>\n6<\/p>\n<p>For example comment following line if there is another sendmail_path : sendmail_path=&#8221;C:\\xampp\\mailtodisk\\mailtodisk.exe&#8221; in the php.ini file<\/p>\n<p>7<br \/>\nAlso remember to restart the server using the XAMPP control panel so the changes take effect.<\/p>\n<p>I can provide sample working\u00a0XAMPP php.ini &amp; sendmail.ini &#8211; download and compare if you have problems sending email&#8230;.with XAMPP\u00a0using gmail&#8230; cost 5$ [PayPal] send email to\u00a0mymac@poliscarhire.com and lsepolis123@gmail.com &#8230;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Send email SAMPLE scripts:<\/strong><\/p>\n<p><strong>PLAIN PHP &#8211; SEND EMAIL STATEMENTS<\/strong><\/p>\n<div>\n<pre>&lt;?php\n\n$email = \"USERNAME3@gmail.com\";\n\n$to = \"{$email}\";\u00a0\n\n$subject = \"Inquiry Contact Us from \". $email;\n\n$headers = \"From:USERNAME@gmail.com\";\n\n$headers .= \"\\r\\nBcc:USERNAME2@gmail.com\";\n\n$headers .= \"\\r\\nReply-To:{$email}\";\n\n$headers .= \"\\r\\nContent-Type: text\/html; charset=UTF-8\";\n\n$headers .= \"\\r\\nMIME-Version: 1.0\";\n\nmail($to,$subject,\"test\",$headers);<\/pre>\n<\/div>\n<p><strong>CAKEPHP &#8211; Controller<\/strong><\/p>\n<pre>&lt;?php\n\n....\n\npublic function emailtothis() {\n $email1 = $this-&gt;request-&gt;data('emailfield');\n $id = $this-&gt;request-&gt;data('idemail');\n \n $listing = $this-&gt;Listings-&gt;get($id, [\n 'contain' =&gt; ['Users', 'Categories']\n ]);\n \n $txt=\"\";\n foreach ($listing as $key =&gt; $value) {\n $txt.=\"{$key} : {$value} , \";\n }\n \n $email = new Email('default');\n $email-&gt;from(['USERNAME@gmail.com' =&gt; 'Polis.town'])\n -&gt;to($email1)-&gt;emailFormat('html')\n -&gt;subject($listing-&gt;name.\" - Polis.town\")\n -&gt;send('Share from Polis.town... &lt;br\/&gt;&lt;br\/&gt;' \n . $listing-&gt;name . '&lt;br\/&gt;' . $listing-&gt;address . '&lt;br\/&gt;'\n . (($listing-&gt;tel !=\"\")?('&lt;a href=\"tel:00357'.$listing-&gt;tel.'\"&gt;'.$listing-&gt;tel.'&lt;\/a&gt;'):('')) .'&lt;br\/&gt;' \n . (($listing-&gt;telMob !=\"\")?('&lt;a href=\"tel:00357'.$listing-&gt;telMob.'\"&gt;'.$listing-&gt;telMob.'&lt;\/a&gt;'):('')) .'&lt;br\/&gt;' \n . (($listing-&gt;email!=\"\") ? ('&lt;a href=\"mailto:'.$listing-&gt;email.'\"&gt;'.$listing-&gt;email.'&lt;\/a&gt;') : ('' )).'&lt;br\/&gt;' \n . (($listing-&gt;url!=\"\") ? ('&lt;a href=\"'.$listing-&gt;url.'\"&gt;'.$listing-&gt;url.'&lt;\/a&gt;') : ( '' )) .'&lt;br\/&gt;'.'&lt;br\/&gt;' \n . $listing-&gt;description.'&lt;br\/&gt;&lt;br\/&gt;'\n . 'long: '. $listing-&gt;long.', lat: '.$listing-&gt;lat); \n \/* *\/\n \/\/die($email1.\", \".$listing-&gt;url);\n return $this-&gt;redirect('\/listings\/view\/'.$id);\n \n }<\/pre>\n<p><strong>CODEIGNITER &#8211; Controller<\/strong><\/p>\n<div>\n<pre>&lt;?php\n\n...\n\n \u00a0 public function sendemail(){\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;load-&gt;library('email');\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;email-&gt;from('USERNAME@cytanet.com.cy', 'lse');\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;email-&gt;to('USERNAME@gmail.com');\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;email-&gt;cc('USERNAME2@gmail.com');\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;email-&gt;bcc('USERNAME3@hotmail.com');\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;email-&gt;subject('Email Test');\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;email-&gt;message('Testing the email class.');\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$this-&gt;email-&gt;send();\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0die(\"email sent\");\n\n\u00a0\u00a0\u00a0\u00a0}<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How to configure XAMPP to send mail from localhost? &nbsp; You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP. So if you are using XAMPP then you can easily send mail from localhost. for example you can configure C:\\xampp\\php\\php.ini and c:\\xampp\\sendmail\\sendmail.ini for gmail to send mail. &nbsp; STEPS &hellip; <a href=\"https:\/\/www.leonidassavvides.com\/blog\/2017\/06\/how-to-configure-xampp-to-send-mail-from-localhost\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to configure XAMPP to send mail from localhost?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,32,43,49,52],"tags":[214,215,221,290],"class_list":["post-594","post","type-post","status-publish","format-standard","hentry","category-mac-os-x","category-php","category-tech","category-windows-10","category-xampp","tag-sample-php-ini","tag-sample-sendmail-ini","tag-send-email-xampp","tag-xampp-setup-email"],"_links":{"self":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/posts\/594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/comments?post=594"}],"version-history":[{"count":0,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/posts\/594\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/media?parent=594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/categories?post=594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.leonidassavvides.com\/blog\/wp-json\/wp\/v2\/tags?post=594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}