» » » How to send an email via WAMP on your localhost

How to send an email via WAMP on your localhost

posted in: Web development

When I develop the email function on my localhost, I like to use the Gmail account for sending an email from my localhost. It is convenient and easy to set up. Today, I will share my method with you how to set up the Gmail account to send an email in your WAMP from your computer. Note, this method works for Windows only. Okay, let’s do it…



Download sendmail.zip

Sendemail.exe is a simple windows console application that emulates sendmail’s “-t” option to deliver emails piped via stdin. It is intended to ease running Unix code that has <code>/usr/lib/sendmail</code> hardcode as an email delivery means. It doesn’t support deferred delivery and requires an SMTP server to perform the actual delivery of the messages.
download sendmail.zip



Install Sendmail

  • Extract and paste the Sendmail folder at this location. => “C:\wamp64\”

Inside the Sendmail folder, find the sendmail.ini and edit the following setting.

  • Save and close the file



Configure php.ini

  • At the wamp icon on the right bottom corner, click on that wamp icon then go to PHP and php.ini. Then follows this setting.
[mail function]
sendmail_path = "C:\wamp64\sendmail\sendmail.exe"
sendmail_from ="your-mailid@gmail.com”
  • Save and restart the wamp server


Test sending an email via your wamp

  • You can use this snippet to test the sending of an email. Simply creates the send_email_testing.php in your web root folder(normally it is www folder) and add the snippet code below.
$to      = 'your-test-email';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
  • Then open your browser(Chrome, IE, Firefox, etc) and test it. Somethings like this. http://localhost/send_email_testing.php
  • After that, you should get the test email in your testing email that you set in the $to variable in the snippet.


Yep, it is easy, isn’t it?



Please make sure before testing the sending an email, you should change the client’s emails that are set in receiver email, CC email, and BCC email. Otherwise, your clients will receive many testing emails from you and they may not happy with your unprofessional mistake.