How to setup WAMP to send emails over the Gmail smtp

Oz's picture

This article explains how to setup WAMP to send emails over the Gmail smtp server using the PHP-function mail().

Software needed

Wamp - Download

Stunnel - Download

Sendmail - Download

Enable POP for your Gmail account
Port 465 (or 587) must be opened to the internet

Short explanation.
The smtp servers of Gmail require SSL authentication. This provides a way of authentication and encryption between your WAMP server and the Gmail smtp servers. This is not supported by default in WAMP. I will explain how this can be added with use of the SSL program "stunnel".

Step 1: Install stunnel-4.33-installer.exe on your WAMP server. Then, open the stunnel configuration file (usually "C:\Program Files\stunnel\stunnel.conf").

Here is my stunnel.conf:
cert = stunnel.pem
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
debug = 7
output = stunnel.log
client = yes
accept =
connect =
;or connect = so there's no DNS lookup

Save these lines to your own stunnel configuration file. Now, stunnel can be started (Start - Programs - stunnel - Run stunnel).

Step 2: Download and extract sendmail to C:\wamp\sendmail\

Step 3: Configure your php.ini file. WAMP has three php.ini files, look in your WAMP welcome screen and cick on "phpinfo()". There you will find the location of the php.ini file which needs to be changed .
Here is my php.ini entry for the mail function:
[mail function]
; For Win32 only.
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i"
SMTP = localhost
smtp_port = 25
Save the changes to your php.ini and STOP-START THE WAMP SERVER!

Step 4: Configure sendmail.ini. The WAMP installation contains sendmail. You will find a folder "sendmail" in your WAMP folder.
Here is my c:\wamp\sendmail\sendmail.ini entry for the mail function:
You should have a working sendmail functionality using Gmail's smtp-servers now!

All good till step 4 :(

I downloaded and extracted the sendmail files into my wamp dir... But there is no sendmail.ini to be found.... there are 3 other sendmail files but not the .ini file. Any suggestions?

Thanks in advance :)

Oz's picture

You might not have the correct sendmail application

It seems there are a couple different sendmail apps out there. The one I am using is from:

I downloaded the archive and unzipped in my wamp directory.

Hopefully this helps

How to setup WAMP to send emails over the Gmail smtp

I followed the steps you gave in setting up wamp server to allow for sending
mails but am still experiencing some major problems.
My mail is not sent and it keeps on timing out.
Would u kindly provide me with assistance please?
Thank you.

Oz's picture

Have you checked the error log files?

On a fresh install I walked through this tutorial and did notice my emails weren't being sent with a simple mail call. I looked in sendmail's error.txt file and noticed this:
12/06/09 11:44:30 : Message is missing sender's address

I adjusted my test script like this:


$from_name = "LocalHost";
$from_email = "";
$headers = "From: $from_name <$from_email>";
$body = "Hi, \nThis is a test mail from $from_name <$from_email>.";
$subject = "Test";
$to = "";

if (mail($to, $subject, $body, $headers)) {
echo "success!";
} else {
echo "fail…";


The email was sent when I included headers. Let me know if this helps, if not, please look in the error logs for more information and add it here.