Wednesday, November 26, 2014

how to configure xampp to send mail in php?




In order to send mail, you have to make some changes in your files if you are using XAMPP. Configure two files, first one is C:\xampp\php\php.ini and the second one is c:\xampp\sendmail\sendmail.ini

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 mailing sites like gmail for your localhost.

In php.ini file find [mail function] and change

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"


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=gmail-id@gmail.com
auth_password=gmail-password
force_sender=gmail-id@gmail.com

Note: Replace gmail-id and gmail-password in above code with yours.

Note: If you are unable to send mail using your gmail accout then you need to make some changes in your gmail account setting like change Access for less secure apps must be enable. Login into your gmail accout and follow the link Gmail setting for less secure apps to configure your gmail account setting.

Click here to get code to send mail using php