Configure Sendmail for WAMP and connect with Gmail in development

Have you installed WAMP into your PC for developing a website and looking for how to send email with it for testing your email feature is working or not? Continue reading this blog.

Unlike XAMP, WAMP does not come integrated with sendmail feature and thus you need to do something extra when you want to test your development waork in your local machiine. To configure WAMP for sending email you need to follow the below steps (assuming WAMP is already installed and working okay):

  1. Download the Fake Sendmail for Windows.
  2. Use Gmail or any other email account to configure the sendmail.
  3. Change te Gmail setting to allow third party email sending feature.
  4. Update the PHP.ini configuration for your website or WAMP server.

Here is the detail elaboration of the steps involved.

Step 1: Download the Fake Sendmail for Windows and put the "sendmail" folder undr your WAMP installation path. Since most of you install WAMP under C:\ drive and assuming that move the "sendmail" folder to "C:\wamp\sendmail"

Step 2: Now configure the "sendmail.ini" file which can be found on "C:\wamp\sendmail". Use the below settings for Gmail. You can configure it for other email also. After changing the "sendmail.ini" file, it will look like below:

; configuration for fake sendmail



Step 3: After setting the sendmail configuration, you need to change the setting (if not already done) in your gmail. Login to your gmail account and goto Settings and enable IMAP Access in your GMail’s Settings -> Forwarding and POP/IMAP -> IMAP Access: Enabled

Also go to google account setting -> Sign-in & Security -> Allow Less Secure Apps: turn it On

Step 4: Open php.ini from “C:\wamp\bin\apache\Apache2.4.9\bin” and configure it as following (The php.ini at “C:\wamp\bin\php\php5.3.x” would not work).

[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = you@yourdomain

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i"

Step 5: Restart WAMP Server

Step 6: Create file "testmail.php" under www folder of WAMP and put the below code inside. Change the to and from email.

$to       = '';
$subject  = 'Testing sendmail feature in WAMP';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From:' . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=utf-8';
if(mail($to, $subject, $message, $headers))
    echo "Email sent";
    echo "Email sending failed";

Congratulations!! You have just send email using sendmail in WAMP.