For this solution you requires sendmail.exe (Its a CLI executable which accepts email from PHP, connects to an SMTP server and sends email). Download the sendmail.zip and follow the steps given below:
Step:1 Configuration of sendmail file
- First of all create a folder named “sendmail” in “C:wamp”.
- Now extract these 4 files: “sendmail.exe”, “libeay32.dll”, “ssleay32.dll” and “sendmail.ini” in the newly created folder.
- Open the “sendmail.ini” file and you have to configure it as following
Step:2 Gmail Account Setting
Step:3 Localhost Server Setting
Step:4 Configuration of php.ini
; For Win32 only.
;smtp_port = 25
; For Win32 only.
;sendmail_from = firstname.lastname@example.org
; For Unix only. Arguments are also allowed.default will be : "sendmail -t -i".
sendmail_path = "C:wampsendmailsendmail.exe -t -i"
- Now Restart WAMP Server.
Step:5 File creation testing
- Create a PHP file and write the following code in it:
$to = 'email@example.com';
$subject = 'Testing sendmail';
$message = 'Hi, you received an email!';
$headers = 'From: firstname.lastname@example.org' . "rn" .
'Reply-To: email@example.com' . "rn" .
'MIME-Version: 1.0' . "rn" .
'Content-type: text/html; charset=iso-8859-1' . "rn" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
echo "Email sent successfully..!!";
echo "Email sending failed";?>
- Next you have to make appropriate changes in $to and $headers variables to set recipient, sender and reply-to address. Save it as “sendmail.php”. (You can save it anywhere or inside any sub-folder in “C:wampwww”.)
- Open this file in browser,and You are DONE..!!
Solutions of Some Known Issues:
- You have to disable the 2-steps-verification in Gmail if you are using GMail’s SMTP server to send email, otherwise you might get “Email sent” message but the email won’t get sent actually. (If you don’t know about 2-steps-verification, then don’t need to worry, it is disabled by default.)
- Please make sure that path to the sendmail.exe contains no “space” (for example, “C:Program FilesPHPsendmail”) otherwise Apache would not be able to locate it.
- If you are using Windows 8 Operating System,then make the following small change.
in sendmail.ini and it’s all working on Win 8 too!