Send email using WAMPSERVER - localhost

Hi everyone,

I’m using WAMPSERVER on my computer and I would like to test sending emails from my website contact form (to my gmail account). What do I need to do?

Or is XAMPP a better option since it apparently includes a mail server?

Thank you in advance!!!

Hey RedBishop,

It’s fairly simple to get email up and running with WAMPSERVER… this tutorial worked for me when I wanted to do the same thing.

Another solution would be to use a library such as PHPMailer or Swift Mailer. You configure them with the details of an email account to send from and they do the rest. They also make it easier than PHP’s mail function to do things like sending attachments.

Hi fretburner,

thank you for replying - you seem to have all the answers! I’ll try it out and hope that it works.

Enjoy the day…

Hi again fretburner,

quick question:

I see that one needs to enter details such as the following below:

Must I provide the password I use for logging in to my gmail account? Isn’t that a security risk? I don’t understand why the password would be required in the first place.

Thank you!

A lot of SMTP (outgoing mail) servers require authentication, to prevent them being used to send spam etc. It doesn’t present a security risk, as your password is in a configuration file that is outside of your web root, so it’s not accessible to users. Besides which, we’re talking about a test setup on your local machine, so unless you share it with anyone the risk is minimal. If it bothers you, you could always create a new gmail account for sending test mail.

Ok, that makes sense. Thanks again!

Hi everyone,

this is a follow up to my previous post about sending email to my gmail account using wampserver (via my website contact form). Something is not working because I’m not receiving any mail.

I’ve unzipped the sendmail folder to the wamp folder, and updated the appropriate fields in the sendmail.ini file with my settings.

Must I leave the following setting as is?

I’ve also edited the php.ini file:

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

; For Win32 only.
sendmail_from =

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

Must the smtp_port = 25 below ; be changed to smtp_port=465? I’m using windows so should my sendmail path not be under “for win32 only”?

I’ve noticed that wampserver has a put online/put offline option. Must this be online when I connect to the internet or is this setting for something else?

I am not sure what I should do to get this to work.

Any ideas? Then please let me know.

Thank you!!

OK, I’ve just checked my own php.ini file and noticed a couple things:

All the options under the mail section are commented out except for the sendmail_path one, and an extra one which sets the log file path:

mail.log = "c:\\wamp\\logs\\mail.log"

Adding this line will let you check the log to see the output from the mail() function, to see if messages were sent etc.

You should also check in the sendmail directory for error.log and check to see if there are any problems.

I know its probably a bit late but I personally would recommend using smtp4dev which catches all email transactions on port 25, I use this all the time at work and at home as its 10x easier than getting a mail server working locally.

Hey Chris, thanks for sharing the link, that looks like a useful tool!

Hey fretburner,

thanks for your help but it’s still not working. Just to confirm, must the smtp port in my sendmail.ini file correspond to the smtp port in the php.ini file? Well I’ve tried all combinations of 25 and 465 and still no luck. I just see an error in the apache_error log file:

[Mon Aug 26 10:23:19 2013] [error] [client] File does not exist: C:/wamp/www/robots.txt

Don’t know if that has any influence.


thanks for the tip. Perhaps that might work.

No, that error is unrelated. As for the smtp port setting in php.ini, that can be commented out as I mentioned in my previous post. Are you getting any output in either of the two log files I mentioned?


the mail log shows To: – Headers: From:

I don’t see any errors. There is no error.log file anywhere in the sendmail directory.

Have you tried looking in the Sent Mail folder from the sending account, as if the mail has actually been sent then it should show up there. If it is, you could also check the spam folder on the receiving account… sometimes mail sent from PHP scripts gets flagged as junk mail.

How can I check the sent mail folder? I’m just adding a random email address and name to my contact form which gets sent to my gmail account. I’ve looked through all the folders in my gmail account and there’s nothing.

But you configured sendmail to send via a gmail account - is it the same account that the email is sent to?

I added my gmail account details to the sendmail.ini file, but I’m under the impression that it is only for receiving mail from my contact form

No, those details are used by sendmail to connect to gmail’s smtp server and send outgoing emails.

Hey fretburner,

then I have no clue what I’m doing.

I have a contact form which gets sent to my gmail address. The address is in the php mail() function. I then access my webpage, fill in a few details in my contact form and press send. Then I log into my gmail account as I normally do and hope to receive the form I just sent.

If this is the wrong way, then what should I do? I’m clearly missing something…

Thank you for your help!!!

Hmm, it’s difficult to know what might be the problem, as you seem to have things set up correctly and you’re not getting any error messages in the log.

Maybe try chris.upjohn’s suggestion and install the smtp4dev tool? I think you’ll probably have to change your php.ini file slightly:

[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 = "d:\\wamp2\\bin\\sendmail\\sendmail.exe -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

; Log all mail() calls including the full path of the script, line #, to address and headers
mail.log = "c:\\wamp\\logs\\mail.log"