How to configure XAMPP to send mail from localhost?
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.
STEPS
1
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.
2
in php.ini file find [mail function] and change
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”
3
Now Open C:\xampp\sendmail\sendmail.ini. Replace all the existing code in sendmail.ini with following code
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com
4
ESPECIALLY For gmail please check https://support.google.com/accounts/answer/6010255 to allow access from less secure apps
SO AS GMAIL TO WORK IN THIS CASE… OTHER THAN GMAIL MAY OR MAY NOT HAVE [SIMILAR] SECURITY NEEDED SETUP.
5
Now you have done!! create php file with mail function and send mail from localhost.
PS: don’t forgot to replace my-gmail-id and my-gmail-password in above code. Also, don’t forget to remove duplicate keys if you copied settings from above.
6
For example comment following line if there is another sendmail_path : sendmail_path=”C:\xampp\mailtodisk\mailtodisk.exe” in the php.ini file
7
Also remember to restart the server using the XAMPP control panel so the changes take effect.
I can provide sample working XAMPP php.ini & sendmail.ini – download and compare if you have problems sending email….with XAMPP using gmail… cost 5$ [PayPal] send email to mymac@poliscarhire.com and lsepolis123@gmail.com …
Send email SAMPLE scripts:
PLAIN PHP – SEND EMAIL STATEMENTS
<?php $email = "USERNAME3@gmail.com"; $to = "{$email}"; $subject = "Inquiry Contact Us from ". $email; $headers = "From:USERNAME@gmail.com"; $headers .= "\r\nBcc:USERNAME2@gmail.com"; $headers .= "\r\nReply-To:{$email}"; $headers .= "\r\nContent-Type: text/html; charset=UTF-8"; $headers .= "\r\nMIME-Version: 1.0"; mail($to,$subject,"test",$headers);
CAKEPHP – Controller
<?php .... public function emailtothis() { $email1 = $this->request->data('emailfield'); $id = $this->request->data('idemail'); $listing = $this->Listings->get($id, [ 'contain' => ['Users', 'Categories'] ]); $txt=""; foreach ($listing as $key => $value) { $txt.="{$key} : {$value} , "; } $email = new Email('default'); $email->from(['USERNAME@gmail.com' => 'Polis.town']) ->to($email1)->emailFormat('html') ->subject($listing->name." - Polis.town") ->send('Share from Polis.town... <br/><br/>' . $listing->name . '<br/>' . $listing->address . '<br/>' . (($listing->tel !="")?('<a href="tel:00357'.$listing->tel.'">'.$listing->tel.'</a>'):('')) .'<br/>' . (($listing->telMob !="")?('<a href="tel:00357'.$listing->telMob.'">'.$listing->telMob.'</a>'):('')) .'<br/>' . (($listing->email!="") ? ('<a href="mailto:'.$listing->email.'">'.$listing->email.'</a>') : ('' )).'<br/>' . (($listing->url!="") ? ('<a href="'.$listing->url.'">'.$listing->url.'</a>') : ( '' )) .'<br/>'.'<br/>' . $listing->description.'<br/><br/>' . 'long: '. $listing->long.', lat: '.$listing->lat); /* */ //die($email1.", ".$listing->url); return $this->redirect('/listings/view/'.$id); }
CODEIGNITER – Controller
<?php ... public function sendemail(){ $this->load->library('email'); $this->email->from('USERNAME@cytanet.com.cy', 'lse'); $this->email->to('USERNAME@gmail.com'); $this->email->cc('USERNAME2@gmail.com'); $this->email->bcc('USERNAME3@hotmail.com'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.'); $this->email->send(); die("email sent"); }