• how to Configure WAMP server to send email in php?

    how to Configure WAMP server to send email in php?

    Bronze Member Asked on August 22, 2016 in Php.
    Add Comment
  • 3 Answer(s)
    Best answer

    Configuring a working email client from localhost is quite a chore, I have spent hours of frustration attempting it. At last I have found this way to send mails (using WAMP,XAMPP, etc.):

    Install hMailServer

    Now you configure this hMailServer Setting:

    1. Open hMailServer Administrator.
    2. Click on Add domain ... button for create new domain.
    3. Under the domain text field, enter your computer localhost IP,
      • Example: is your localhost IP.
    4. Click on the Save button.
    5. Now you Go Settings > Protocols > SMTP and select "Delivery of Email" tab
    6. Find localhost field enter "localhost".
    7. Click on to a Save button.

    Configure your Gmail account, perform following modification:

    1. Go to Settings > Protocols > SMTP and select "Delivery of Email" tab
    2. Enter "smtp.gmail.com" in the Remote Host name field.
    3. Enter "465" as the port number.
    4. Check "Server requires authentication".
    5. Enter your Google Mail address in the Username field.
    6. Enter your Google Mail password in the password field.
    7. Check mark "Use SSL"
    8. Save all changes.


    If you want to send email from another computer you need to allow deliveries from External to External accounts by following steps:

    1. Go to Settings > Advanced >IP Ranges and double click on "My Computer" which should have IP address of
    2. Check the Allow Deliveries from External to External accounts Checkbox.
    3. Save settings using Save button.
    Bronze Member Answered on August 22, 2016.
    Add Comment

    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 calledsendmail 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


    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






    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



    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.


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

    Bronze Member Answered on August 22, 2016.
    Add Comment

    Now a days there are always tasks which require email notification, such examples are notify user on account creation, periodic notification for activities done by user, notify user on submission of form, etc. There are lots of other cases where you need to test the email and its content. In this post I’ll be telling how can we send an email from our localhost.

    FYI: Since Google Mail has changed its SSL security and removed support for v2 which is used by Sendmail.exe, those who will be configuring their GMail account will need to configured the Stunnel as well [Read More].

    What you’ll need:

    • WAMP Server, download and install latest version. I’m using 2.2E 64Bits
    • Fake Sendmail for Windows
    • An email account with any email providers, I’m using GMail account.
    • Stunnel (if Fake Sendmail itselft doesn’t work)

    Install the WAMP Server downloaded from WAMP Server site. By default it is installed in “C” Drive, at “C:\” location, keep it same so its easy to access.

    Next download Fake Sendmail for Windows. Fake Sendmail, aka sendmail.exe, is a simple windows console application that emulates sendmail’s “-t” option to deliver emails. Extract the sendmail.zip file and move the folder here: “c:\wamp\sendmail”. So your “sendmail.ini” file location will be like this “c:\wamp\sendmail\sendmail.ini”

    To send an email we will need an email account with 1 step verification i.e. username and password (2 step verification will not work in this case). Now we’ll need to configure some settings in sendmail.ini, which can be found in “c:\wamp\sendmail”.

    • Line no. 14 | smtp_server=smtp.gmail.com # if gmail, if configured with stunnel use localhost
    • Link no. 18 | smtp_port=465 # if gmail, if configured with stunnel use 25
    • Link no. 27 | smtp_ssl=auto # if gmail, if configured with stunnel use none
    • Link no. 46 | auth_username=youremail@gmail.com
    • Link no. 47 | auth_password=yourpassword

    There will be some lines which needs to be commented in sendmail.ini, please refer mysendmail.ini for reference.

    Once we’ve configured sendmail.ini we’ll need to configure php.ini. To open currently used PHP.ini file see [Screenshot1]:

    In php.ini file search for sendmail_path and set its value as:
    sendmail_path = “C:\wamp\sendmail\sendmail.exe -t”
    Assuming you’ve not change any of the path from above.

    Save and close php.ini file.

    For these changes to take effect you must need to restart your WAMP Server.

    By now you should be able to send emails, but if you’re using Windows 8 or using GMail like me, then you’ll need to do few more configurations, like I did:
    These few more configurations includes installing and configuring Stunnel, and configuring Sendmail with Stunnel.

    • Download Stunnel form Stunnel site and install.
    • Locate your stunnel.conf file to configure, either using start menu or by going to “C:\Program file\stunnel” for 32Bits and “C:\Program file (x86)\stunnel” for 64Bits.
    • To edit this file you’ll need administrative permissions, so just copy this file to Desktop and make necessary changes and then replace the original file in above location. Following are the changes you’ll need to do:
      cert = stunnel.pem
      socket = l:TCP_NODELAY=1
      socket = r:TCP_NODELAY=1
      key = stunnel.pem
      accept  = 465
      connect = 25
      client = yes
      accept =
      connect = smtp.gmail.com:465
      ; To check logs you can enable logging using following lines
      debug = 7
      output = stunnel.log ; You will need to create this file if doesn't exists already and give proper permissions to current user.
    • Run Stunnel (Everytime you make any changes in stunnel.conf you’ll need to reload it using “configuration => Reload Stunnel.conf”)
    • Make sure you’ve made changes provided above with comment saying for stunnel
    Bronze Member Answered on August 22, 2016.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.