Category Covered

How to send mail from localhost

If you get the error like "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() "
If you want to send email from your local server or localhost application then you need to

Follow the steps:

Sendmail extension needs to be download the from the follwing link

Extract it keep the sendmail folder  inside wamp folder so it looks like here  D:\wamp\sendmail\sendmail.ini
Now you need to configure some important parts to send mail from localhost

How to configure:

1. Open sendmail.ini file which is located at D:\wamp\sendmail\sendmail.ini

Now do the following changes i mean modify the sendmail.ini //Dont change the line
smtp_port=465 //only gmail address

2. Modification on php.ini
Go modigy the php.ini file and set the sendmail_path to the following

sendmail_path ="D:\wamp\sendmail\sendmail.exe -t"
Note: Make sure restart your WAMP server and you are done.

3. Now you need to enable your IMAP on gmail.
See the image as follows

4. Copy the php code and make a php file and run it from your local server. I think you are done!!

<?php mail("","My subject",'My email body');?>

5. Also you need to enable openssl extension of php . Follow the image so it will be clear for you


6. Make sure that to login in your gmail account you dont need the mobile verificaiton.(Disable the mobile auth security i mean disable two step security)