Skip to content →

How to set up email with WAMP

Development sites and production sites; host and local servers

When I develop a new website, say for my blog, I set up a mock version on my laptop. In techy-speak, I am using a “development site” on a “server” on “local host”.  When the website is ready, I move it to my hosting service (in my case Dreamhost in the US). That is my “production site” and the website will thereafter physically reside on their servers and they will be the host.

Set up WAMP

I use a standard laptop to develop my websites. This one has Windows 7. My last one had Windows XP, and so on.  To set up my local server, I download WAMP.  As I only download WAMP when I have a new computer, I follow the instructions on LifeHacker, which are very clear.

Basically, I arrive at an arrangement where I have

  • A directory in C: called C:wamp
  • A program under C:ProgramFiles called WampServer where I can fire up WAMP (I leave WAMP off when I am not using it)
  • Within C:wamp is C:wampwww where my websites are stored
  • And within WampServer is access to localhost, PHP and MySQL.  PHP runs the server and MySQL sets up databases to store blogs.

It is all rather baffling at first but set aside a quiet Sunday afternoon and work methodically.  You will manage fine.

Set up email for a development site on WAMP

This post is about setting up email to work with a development site. I never bothered to set it up for my WordPress mockups because I already knew how WordPress worked and I could fast forward in my mind to what the production site would look like.  But yesterday, I downloaded Elgg to develop a social network and I really wanted to test the email functionality.  So this is how I set up email functionality for WAMP.

The basic principles are that I downloaded an email service called sendmail and I edited my PHP.ini file.  Both are easy and I will go into the details just now. This paragraph is to record an important point.  The set up changed the default email in the PHP.ini file. This is why that matters.  It is highly probable that each development site has a different email address.  The solution in this email assumes that the same email address is used with every site.  Either use the same email address for all your development sites or remember to change the sendmail.ini each time you change sites (and possibly the php.ini as well).  Whatever, don’t be surprised if something breaks. This could be the cause.

How to set up email for WAMP in three steps

#1 Download sendmail into a the c:wampbinsendmail

You will know you are in the right place because  bin has directories for PHP and MySQL

#2 Edit sendmail.ini in a text editor

I linked to a gmail account so at the date of writing (April 2012), look for these lines and fix them accordingly

smtp_server=smtp.gmail.com

smtp_port=587

smtp_ssl=tls

auth_username=youremailaddresses@gmail.com

auth_password=youremailpassword

NB I am using an email address that works with Google Apps so the gmail.com in my email address actually read myname@mydomainname.com

Save!

#3 Edit your php.ini file

On my version of Windows 7, I start my WampServer by finding it on the All Programs list. Then I look on the bottom tool bar for an upward arrow.  I activate WAMP with the big W.  Once it turns green, I can find everything that comes with WAMP.

I select PHP and open PHP.ini in a text editor.  I find “mail function” and I will now edit it out all mail settings AND add a path directing WAMP to the sendmail that I just set up.  These are the important lines.

[mail function]

; For Win32 only.

; http://php.net/smtp

; SMTP =

; http://php.net/smtp-port

; smtp_port = 25

 

; For Win32 only.

; http://php.net/sendmail-from

; sendmail_from = an email address that is already there

 

; For Unix only.  You may supply arguments as well (default: “sendmail -t -i”).

; http://php.net/sendmail-path

sendmail_path = C:wampbinsendmailsendmail.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 =

In short, make sure all the lines but one start with a semi-colon and copy the path line above.

Save!

And restart your server by pressing the arrow on the tool bar, selecting W, and “restart all services”.

Done

Now test your email service. You should be able to send an email from Elgg (or any other service). So try it – send an email from your development website (the email address does match what you put in sendmail.ini, right?) to another of your email addresses and go to see it it arrives within seconds.

Done!  You have set up email functionality in WAMP.

Make your own notes so you can do it again. And importantly, recall what you have done when you move to a production site or start another development site.  Write your own notes!  It only takes a few minutes!

CHECK OUT SIMILAR POSTS

Published in SOCIAL MEDIA & IT

48 Comments

  1. steve steve

    THANK YOU!!! I have been pulling my hair out trying to work on a Joomla website locally and have spent my whole day trying to figure out how to send email. I cannot tell you how many HUNDREDS of blog sites on Joomla I’ve been to and found so many people with the same problem but no solutions. You are the only one who’s solution worked for me — my wamp was missing the email setup! Thank you again! I’ll have to come back and check out your blog further another time. Peace!

  2. John John

    I followed your directions to the letter, and it seems to work in that I no longer get a php error with WAMP when using the mail() function on a page, but the emails are not arriving in my gmail account. Everything is typed correctly with the proper information. Could there be something else that might be preventing a delivery once it is sent with mail()?

    • CVD CVD

      Same…

  3. John John

    I solved it. I need an application specific password for sendmail since I have that security feature turned on for google. I just need to figure out how to use one for sendmail.

  4. […] mail yollayamadım bende bu wampın mail serverini nasıl ayarlarım diye biraz araştırdım ve bu kaynağı buldum Ve Türkçe Anlatımını yapmaya karar verdim hemen kuruluma geçelim fazla […]

  5. Hitesh Parikh Hitesh Parikh

    Thanks for the great help on this. I would appreciate this article. You are such a helpful human.

  6. Anand Anand

    Mr. John
    With a very kind request I wanna ask you hoe you overcome your problem. I am facing the same problem and want your help at once

  7. tolu93 tolu93

    please where can i download the sendmail

  8. Thanks for this, I do most of my development work on wamp but have to load on to my server to check email features, this will save me loads of time.

  9. Sheena Sheena

    Thank you very much for this! You are such a great help to me. Thank you!

  10. Mohammed Mohammed

    Can u pls tel me wer can i download sendmail ? pls do a needfull help buddy…………

  11. Omi Omi

    Thank you so much!! Amazingly simple article and things worked very smoothly! 🙂

  12. Thank you so much! I finally found the way to test my application completely with WAMP

  13. Koros K kenedy Koros K kenedy

    Thanks alot, again and again After going through your advice am sure it will help me…mine too was wamp hosted in my pc and I want pple in the LAN to register but it kept syaing could not instatiate mail function……thanks alot

  14. Dibyendu Dibyendu

    I have written a php script using senmail, and saved it in “C:wampwwwmail.php”

    i have made all the above said changes in php.ini & sendmail.ini

    but when i am running the code “localhostmail.php”

    error showing.

    Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:wampwwwmail.php on line 9
    Failure: Email was not sent!

    Anyone here please help me, i have spend already 1½ day in sending php mail using my gmail account. But nothing is working. Please help me guys. Thank you in advance

  15. David David

    I had to disable the pop3 authentication for mine to work. If anyone doesn’t get it to work, I highly suggest uncommenting the line debug_logfile=debug.log (remove the ; ) and view the log file.

    Thank you Jo!

  16. thanks for the good tutorial, to be honest the most clear and simple tutorial that i fond all the details is there, very great job , thanks a lot

  17. jason jason

    iv done all the above dont get any errors but i do not recieve any emails help please 🙁

  18. Nimesh Nimesh

    It didnt work for me at first. I checked the error log and found the error as “11/09/23 22:07:05 : Message is missing sender’s address”. I was using mail(“receiver@mail.com”, “Subject”, “Message”) format and I changed the format to mail(“receiver@mail.com”, “Subject”, “Message”, “From: sender@mail.com“) and it worked.

    So if your sendmail is not working, check error.log file as it will be more helpful (not all errors and warnings are displayed in browser)

  19. mark lightfootq mark lightfootq

    Hi, I have not got a sendmail file in my wamp folder can you help please

  20. phpfriend phpfriend

    Hey thanks a lot, this worked fantastic for me 🙂

    took me 5 mins, and I will now make my own notes 😉

  21. Bassam Bassam

    Thanks. Very helpful!

  22. Alexandre Alexandre

    Thanks thanks thanks!!! I had been looking for a easy solution and you give me THE EASY solution!

  23. Hitesh Kumar Sharma Hitesh Kumar Sharma

    Thanks Dear,
    This text help me a lot.
    I was searching for this from last 15 days.
    and finally i send the mail from my PHP script using you solution.

    Thanks a lot!!!

  24. Same issue as Dibyendu above. Running a simple php mail() call results in warning:

    [Mon Oct 29 16:03:50 2012] [error] [client 127.0.0.1] PHP Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\Custom\incs\testmail.PHP on line 7, referer: http://localhost/Custom/incs/

    Did anyone figure out the probably issue. I am a WAMP newby so I might be screwing it up – but I have followed the above to a t.

  25. Aniketh Aniketh

    Hi,

    Everything went fine but haven’t received any email in my inbox.

    Have setup as per you.

    Please reveiw the code I have used

  26. Aniketh Aniketh

    Hey got this in error log fle

    ‘C:wampbinsendmailsendmail.exe’ is not recognized as an internal or external command,
    operable program or batch file.
    ‘C:wampbinsendmailsendmail.exe’ is not recognized as an internal or external command,
    operable program or batch file.
    ‘C:wampbinsendmailsendmail.exe’ is not recognized as an internal or external command,
    operable program or batch file.
    ‘C:wampbinsendmailsendmail.exe’ is not recognized as an internal or external command,
    operable program or batch file.
    ‘C:wampbinsendmailsendmail.exe’ is not recognized as an internal or external command,
    operable program or batch file.
    ‘C:wampbinsendmailsendmail.exe’ is not recognized as an internal or external command,
    operable program or batch file.

  27. Aniketh Aniketh

    Also when I use
    sendmail_path = “C:\wamp\sendmail\sendmail.exe -t -i”

    get message which is define in my else coz of above code

    and if I use

    sendmail_path = C:wampbinsendmailsendmail.exe -t

    as per you ..get message as Email sent which I should receive if mail function works…..

    But problem is I don’t receive any email in my inbox.

    Please help it’s do or die for me.

    Thanks
    Ani

  28. Aniketh Aniketh

    My code:-

  29. ijaz ijaz

    i follow athe steps.but my email not send yet.and i use eldd 1.8.9

  30. I am getting the error

    Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\email\mail.php on line 4

    Please help me ASAP

  31. James James

    Thanks for this useful tutorial. Got it working for me.

    One thing: it took me a little while to figure out that the php.ini file I needed to edit was the one in the wamp/bin/apache/Apache[version]/bin directory rather than that in wamp/bin/php directory. Thought this might be worth mentioning in case it catches anyone else out.

  32. Jona Jona

    Hello, I did this the first time by installing wamp server and a joomla site from scratch and it worked perfectly. But now I moved a joomla website from an online server and it doesn’t work now. I don’t get any error messages but emails are not being sent. Anyone can help?

    Thank you.

  33. Worked like a charm. Brilliant tutorial. Many thanks.

  34. Khoa Khoa

    I am also getting this error. can someone help please

    Warning: mail(): Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:\wamp\www\email\mail.php on line 4

    • Khoa Khoa

      ^Disregard. After putting the sendmail in the bin folder AND realizing i put the path under sendmailfrom, everything works flawlessly 🙂

  35. Thanks for sharing
    but unfortunately not working for me

  36. saran saran

    hi

  37. mohankrishna mohankrishna

    Maximum execution time of 30 seconds exceeded in C:\wamp\www\send-mail.php on line 10
    Call Stack
    Connection Closed Gracefully.

  38. Hello there! This is my first visit to your blog!
    We are a group of volunteers and starting a new initiative in a community in
    the same niche. Your blog provided us valuable information to work on.
    You have done a marvellous job!

  39. Very informative article to send email with php. Thank you

  40. Cliff Cliff

    After installing, I had the same errors you all did. I ended up adding the semi-colons in the spots suggested as well as ran into the similar problem with no error, but mail not being sent. The log stated:

    ** Message is missing sender’s address

    So I went into sendmail.ini and modified this line:

    force_sender=

    Once an address was set, it worked perfectly.

  41. Thanks a lot. It was really useful for me.

  42. bahman bahman

    thank you to share this article.

    this method dosn’t work for me.

    Received Error:
    Connection Timed Out.

  43. Raj Kothari Raj Kothari

    Thank You for helping I was really in trouble

  44. Chea Chea

    Can sendmail use with cPanel, or with Debian?

  45. Nkemeni Valery Nkemeni Valery

    Thank you very much, I really do appreciate

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.