How To: PHP Sendmail and XAMPP on Windows

It can be difficult getting the PHP’s default mail functions to work when you run an apache server on windows instead of a unix environment.

Comments 57

  1. kelvin wrote:

    Initially, I did it my way and got this error from the log file:
    Socket Error # 10061Connection refused
    I latter did it your way and it was taking a lot of time. I checked the log file and found this error :
    Connection Closed Gracefully.

    Posted 25 Apr 2009 at 8:30 am
  2. brett wrote:

    Did you end up receiving the email? If not, which log file did you see that error in?

    Posted 25 Apr 2009 at 8:32 am
  3. byron wrote:

    some anti-virus product limit what applications are allowed to send mail via port 25 (SMTP). ensure that sendmail.exe is in your list of approved applications.

    Posted 27 Apr 2009 at 7:10 am
  4. Totte wrote:

    Hi,
    I get the error
    09/04/27 14:36:56 : Must issue a STARTTLS command first
    with this setup..
    seems like my xampp is not using tls?

    any hints?
    -totte

    Posted 27 Apr 2009 at 4:38 pm
  5. Totte wrote:

    @Totte
    I added the two dll’s and the error changed to
    09/04/27 14:41:17 : Range check error

    -totte

    Posted 27 Apr 2009 at 4:43 pm
  6. brett wrote:

    @Totte
    Would you mind posting your sendmail.ini file? — taking care to remove any personal information such as username / pass / email, etc.

    Posted 27 Apr 2009 at 4:45 pm
  7. Totte wrote:

    Hi again,
    My xampp now works, with your settings and those dlls. It seemed I had to not only restart xampp, but also firefox to avoid that Range Check error.
    Great, thanks!

    Posted 27 Apr 2009 at 4:50 pm
  8. brett wrote:

    @Totte
    Good to hear, glad you got it working.

    Posted 27 Apr 2009 at 5:42 pm
  9. Totte wrote:

    Actually, it did not work. I mistakenly was visiting my “real” server

    I get the error
    09/04/27 15:54:33 : Range check error

    And I found this about the dll that downloads from your page

    http://www.greatis.com/appdata/d/s/ssleay32.dll.htm

    does not look good.. ?

    Posted 27 Apr 2009 at 6:00 pm
  10. brett wrote:

    @Totte
    No, the DLL is fine. Maybe Byron, who posted above, can help determine what that error means. He is actually the developer of the program. On the fake sendmails site, here is a quote from the troubleshooting section:
    “i’ve had a few reports of sendmail returning a “range check error”. i have tracked this to a bug in the indy sockets library and it has been fixed in version 18.”
    Link: http://glob.com.au/sendmail/

    In the meantime, would you mind posting your configuration ini? Be sure to take out any private info.

    Posted 27 Apr 2009 at 6:47 pm
  11. Totte wrote:

    Thanks,
    well, the range check error comes after like 1 minute “processing”…

    Anyway, here is my sendmail.ini

    -totte
    ; configuration for fake sendmail

    ; if this file doesn’t exist, sendmail.exe will look for the settings in
    ; the registry, under HKLM\Software\Sendmail

    [sendmail]

    ; you must change mail.mydomain.com to your smtp server,
    ; or to IIS’s “pickup” directory. (generally C:\Inetpub\mailroot\Pickup)
    ; emails delivered via IIS’s pickup directory cause sendmail to
    ; run quicker, but you won’t get error messages back to the calling
    ; application.

    smtp_server=smtp.live.com

    ; smtp port (normally 25)

    smtp_port=25
    smtp_ssl=auto

    ; the default domain for this server will be read from the registry
    ; this will be appended to email addresses when one isn’t provided
    ; if you want to override the value in the registry, uncomment and modify

    default_domain=monkisoft.com

    ; log smtp errors to error.log (defaults to same directory as sendmail.exe)
    ; uncomment to enable logging

    error_logfile=error.log

    ; create debug log as debug.log (defaults to same directory as sendmail.exe)
    ; uncomment to enable debugging

    ;debug_logfile=debug.log

    ; if your smtp server requires authentication, modify the following two lines

    auth_username=********
    auth_password=*******

    ; if your smtp server uses pop3 before smtp authentication, modify the
    ; following three lines

    ;pop3_server=
    ;pop3_username=
    ;pop3_password=

    ; to force the sender to always be the following email address, uncomment and
    ; populate with a valid email address. this will only affect the “MAIL FROM”
    ; command, it won’t modify the “From: ” header of the message content

    force_sender=

    ; sendmail will use your hostname and your default_domain in the ehlo/helo
    ; smtp greeting. you can manually set the ehlo/helo name if required

    hostname=localhost

    Posted 28 Apr 2009 at 12:17 am
  12. byron wrote:

    make sure you’re running the latest version (i don’t know what version xampp distribute).

    failing that i’ll really need the log files and stack traces; follow the instruction on the sendmail site if you require direct assistance from me :)

    Posted 28 Apr 2009 at 12:22 am
  13. brett wrote:

    @byron
    Thanks for following up.

    Totte, here is the help link: http://glob.com.au/sendmail/help/

    Post back when you figure it out!

    Posted 28 Apr 2009 at 7:33 am
  14. Totte wrote:

    Hi, I tried the new version of xampp with sendmail and get the same errors. Im using mercury instead.. would be nice to get it working though. I will try it on another machine later on.

    Posted 29 Apr 2009 at 12:03 pm
  15. gordee wrote:

    Hi. thanks for the post, it is the most helpful I’ve found anywhere and really has dissolved a huge amount of frustration. Thanks again.

    Posted 23 Jul 2009 at 10:00 am
  16. brett wrote:

    @gordee
    I’m glad it helped.

    Posted 24 Jul 2009 at 1:11 pm
  17. Sri wrote:

    Hi

    I am trying to send email to my gmail account using PHP contact us page and getting real hard time. I followed all the steps mentioned by you in this very simple blog. But unfortunately I am getting connect time out error. I am using wamp server 2.0 with fake sendmail program with ssl. Changed all the necessary configuration entries but none worked. Although my contact us page says, the email sent successfully. Not sure where is the issue?

    Posted 10 Aug 2009 at 1:16 pm
  18. brett wrote:

    @Sri
    It is a little hard to tell without knowing anything about the contact us script or your server configuration. With that info, I can’t tell whether it is a problem with sendmail or the script. Maybe you could contact the developer of the script.

    Posted 16 Aug 2009 at 9:18 am
  19. roxy wrote:

    Thank you! This worked like a charm.

    Posted 12 Sep 2009 at 3:28 pm
  20. Shariff wrote:

    i followed the procedure u have written and ended up with this

    ……………………………………………………………………………..

    Warning: mail() [function.mail]: Failed to connect to mailserver at “smtp.gmail.com” port 465, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:\xampp\htdocs\sendmail.php on line 26

    Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\sendmail.php on line 27

    this error comes when i use ini_set() in mail file that is

    ini_set(sendmail_from,”********@gmail.com”);
    ini_set(SMTP,”smtp.gmail.com”);
    ini_set(smtp_port,”465″);
    …………………………………………………………………………

    but when i remove this and change my php.ini
    as

    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    SMTP = smtp.gmail.com

    ; http://php.net/smtp-port
    smtp_port = 465

    ; For Win32 only.
    ; http://php.net/sendmail-from
    ;sendmail_from = *******@gmail.com

    sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\”-t”

    i get this error

    Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 … Relaying denied. IP name lookup failed [117.192.137.222] in C:\xampp\htdocs\sendmail.php on line 23

    ………………………………………………………………………………
    ……………….
    both errors accompany me after i changed the sendmail.ini file

    and i have also added these two files libeay32.dll and ssleay32.dll

    [sendmail]
    smtp_server=smtp.gmail.com
    ; smtp port (normally 25)

    smtp_port=465

    ; SMTPS (SSL) support
    ; auto = use SSL for port 465, otherwise try to use TLS
    ; ssl = alway use SSL
    ; tls = always use TLS
    ; none = never try to use SSL

    smtp_ssl=auto
    default_domain=gmail.com

    auth_username=********@gmail.com
    auth_password=**********

    …………………………………………………………………….

    can u please tell me what is the actual problem i am facing ……….. help would be appreciated and grateful….

    Posted 24 Nov 2009 at 11:52 am
  21. newdee wrote:

    ei buddy, im researching for my project to work, glad you can help me… I have this simple script
    /////

    ////

    And i want it to be send on a yahoo mail, just to test if my xampp is working.. i’m having trouble because your topic is about Gmail, yet mine wants to be on Yahoo.. also i’m having trouble locating those *.ini files… can you please guide me friend :(

    Posted 25 Nov 2009 at 2:25 pm
  22. master wrote:

    EI buddy can you please help me, is this applicable if i want to send an email coming from my localhost XAMPP to yahoo mail?

    This is my script I created, is this right, mate?

    Posted 25 Nov 2009 at 2:29 pm
  23. brett wrote:

    The sendmail directory is located in the XAMPP install directory — that is where the *ini files should be. Yahoo should also work, just change the smtp settings accordingly.

    newdee :

    ei buddy, im researching for my project to work, glad you can help me

    Posted 25 Nov 2009 at 5:09 pm
  24. brett wrote:

    Can’t see your script, sorry. Try the Contact form.

    master :

    EI buddy can you please help me, is this applicable if i want to send an email coming from my localhost XAMPP to yahoo mail?

    This is my script I created, is this right, mate?

    Posted 25 Nov 2009 at 5:10 pm
  25. Robert M. wrote:

    You are a genius, Brett – thanks a million – finally all is working as it should on my Apache XAMPP using Gmail. Fantastic work worth financial rewards. I do like to donate tell me how
    Robert M.

    Posted 10 Jan 2010 at 10:43 pm
  26. brett wrote:

    Glad I could help, Robert. I put up a donate button on the right sidebar, but don’t feel obligated :)

    Robert M. :

    You are a genius, Brett

    Posted 11 Jan 2010 at 6:25 am
  27. salang wrote:

    The sendmail.ini in my xampp sendmail folder looks different from yours and the contents are as follows. Can you tell me why? My version xampp is 1.7.3

    # Example for a user configuration file

    # Set default values for all following accounts.
    defaults
    logfile “C:\xampp\sendmail\sendmail.log”

    # Mercury
    account Mercury
    host localhost
    from postmaster@localhost
    auth off

    # A freemail service example
    account Hotmail
    tls on
    tls_certcheck off
    host smtp.live.com
    from [exampleuser]@hotmail.com
    auth on
    user [exampleuser]@hotmail.com
    password [examplepassword]

    # Set a default account
    account default : Mercury

    Posted 16 Jan 2010 at 4:53 am
  28. brett wrote:

    Just copy and paste the configuration of my sendmail.ini file (above) into yours, follow the rest of the instructions, and see if that works. It is not supposed to be exactly how my setup is by default.

    Posted 16 Jan 2010 at 11:06 am
  29. viduph wrote:

    Could you please help me? Here are the steps I followed:
    1. Modify php\php.ini (My XAMPP version is 1.7.1 and I cannot find apache\bin\php.ini)
    2. Modify sendmail\sendmail.ini
    3. Download sendmail_ssl.zip file (this step is done after I did not get success without it)
    4. Restart Apache
    5. Run send mail script

    But all I get is no response, no error log file is created.
    Here is the script to send email:

    $from_name = “my name”;
    $from_email = “myemail@gmail.com”;
    $headers = “From: $from_name “;
    $body = “Hi, \nThis is a test mail from $from_name .”;
    $subject = “Test mail from $from_name”;
    $to = “myotheremail@gmail.com”;
    if (mail($to, $subject, $body, $headers)) {
    echo “success!”;
    } else {
    echo “fail

    Posted 20 Jan 2010 at 4:35 am
  30. brett wrote:

    I’m not sure what your problem is. Try printing your variables on the screen as debug at various points to ensure they are what you think they should be.

    Posted 20 Jan 2010 at 10:00 pm
  31. alexg wrote:

    I am running XAMPP on vista and followed your instructions carefully. My example ini file under sendmail/xampp/xampp didn’t look like a proper ini file but more like what salang has posted here. I used a modified copy of your ini file and sendmail was complaining about the syntax of the ini file at line 1. After some time and a lot of frustration I replaced my sendmail.exe with a fresh download from their website at http://glob.com.au/sendmail/ and now it works like a charm. Seems some versions of XAMPP are bundled with a sendmail that expects the ini file in some other weird format. Hope someone finds this useful.

    Posted 03 Feb 2010 at 5:35 am
  32. brett wrote:

    Thanks! I’m sure visitors will find this information useful.

    Posted 03 Feb 2010 at 7:19 am
  33. Ting wrote:

    Thank you for your any comments. I did what you said and still did not receive my confirmation email. I am using XAMPP version 1.7.2. My sendmail.ini is like follow, I did what you told us at PHP.ini and restart Apache :
    ; configuration for fake sendmail
    [sendmail]
    smtp_server=smtp.telus.net
    smtp_port=465
    ; SMTPS (SSL) support
    ; auto = use SSL for port 465, otherwise try to use TLS
    ; ssl = alway use SSL
    ; tls = always use TLS
    ; none = never try to use SSL
    smtp_ssl=auto
    default_domain=brettshaffer.com
    error_logfile=error.log
    ; if your smtp server requires authentication, modify the following two lines
    auth_username=xxxx@telus.net
    auth_password=xxxx

    Posted 11 Feb 2010 at 2:17 pm
  34. JustMe wrote:

    Hello!

    I have a problem:
    - i get the sended email but i have a 5-8 seconds delay before the email is send…on localhost(the localhost webpage is hold for 5-8 seconds)!

    i use xampp 1.7.3 on windows xp sp3

    Could somebody help me?
    Thank you

    Posted 13 Feb 2010 at 8:01 pm
  35. brett wrote:

    So the email is sent, but you are unhappy with the speed / duration taken to send the email? It probably has to do with either your web server and/or your SMTP server.

    Posted 17 Feb 2010 at 9:37 pm
  36. Take wrote:

    I get error like this:

    Warning: mail() [function.mail]: SMTP server response: 571 info@ubzrs.org prohibited. We do not relay in C:\xampp\htdocs\rapid\mail.php on line 6 , anyone know what this mean?

    Posted 24 Feb 2010 at 12:48 pm
  37. J wrote:

    I’m getting the following error when I try to launch a php file that performs an email:

    Warning: mail() [function.mail]: SMTP server response: 530 SMTP authentication is required. in C:\xampp\htdocs\contact_parse.php on line 35
    return_msg=Thanks , your message has been sent.

    No email has been received btw.

    Posted 25 Feb 2010 at 9:48 am
  38. Judd Rogers Watts wrote:

    Hi:
    I have XAMPP running on my IBM Netvista (P4); it works well and I am very pleased with it. I have a PERL program that uses SENDMAIL which works on my Network Solutions hosting service. I’m importing it to XAMPP.

    The program opens SENDMAIL with the following code:

    my $sendmail = “/usr/sbin/sendmail -t”;
    open(SENDMAIL, “|$sendmail”) or die “Cannot open $sendmail: $!”;

    and prints the email document with lines like:

    print SENDMAIL $from;
    print SENDMAIL $send_to; #etc.

    I believe I need to modify the PERL open statement. I have tried:

    $sendmail = “C:\xampp\sendmail\sendmail”;
    open(SENDMAIL, “|$sendmail”) or die “Cannot open $sendmail: $!”;

    but had no luck. Also, I think I need an .ini file. I tried the following file:

    C:\xampp\sendmail\sendmail.ini

    with this as the file contents:

    c:\xampp\sendmail\sendmail
    smtp_server=smtp.bankmanasseh.com
    smtp_port=30
    default_domain=bankmanasseh.com
    error_logfile=error.log
    auth_username=********@bankmanasseh.com
    auth_password=*******

    (bankmanasseh.com is my Network Solutions hosetd URL.) It still doesn’t work. I got no errors, no error log, and no email was sent. Can you help me?

    Signed: Judd Rogers Watts
    Owner of Manasseh

    Posted 02 Mar 2010 at 9:53 pm
  39. Lorraine wrote:

    OMG I love you! I have been banging my head against a brick wall for weeks trying to get XAMPP working to send mail. I have read through so many pages and not found a clear, simple explanation. I cannot thank you enough for posting this information.

    Posted 16 Mar 2010 at 11:30 am
  40. brett wrote:

    Glad you got it working

    Posted 23 Mar 2010 at 12:18 pm
  41. brett wrote:

    Hello,

    First off, I would strongly advise against posting your username and password for anything online. I have inserted asterisks in place for your protection, however, I would recommend you change your password immediately.

    Second, I wrote this post a while ago and have since moved away from XAMPP and windows, so this just isn’t fresh enough in my mind to determine what is wrong. I would suggest emailing the author of the script or posting on the XAMPP forums.

    Good luck.

    Posted 23 Mar 2010 at 12:22 pm
  42. Rudolph wrote:

    Hey, thank you. For the last few days, I have been stressed from not being able to configure the mail function. Now, you provided a solution that works. No more stress meds.

    Thank you

    Posted 07 Apr 2010 at 9:16 pm
  43. Prateek wrote:

    smtp_port=465
    ; SMTPS (SSL) support
    ; auto = use SSL for port 465, otherwise try to use TLS
    ; ssl = alway use SSL
    ; tls = always use TLS
    ; none = never try to use SSL
    smtp_ssl=auto

    My sendmail.ini does not have these lines!!!!!!!!

    Posted 13 Apr 2010 at 6:31 pm
  44. brett wrote:

    Have you tried putting them in?

    Posted 14 Apr 2010 at 6:49 am
  45. qkfsiuy wrote:

    J1qOvf rqfewlbgyiha, [url=http://hkvkzzslvldw.com/]hkvkzzslvldw[/url], [link=http://bmhjnkjlvess.com/]bmhjnkjlvess[/link], http://mjibnpvenisg.com/

    Posted 22 Apr 2010 at 11:31 pm
  46. antony wrote:

    it isn

    Posted 26 May 2010 at 4:10 am
  47. Zia wrote:

    I am running 5 websites on my server. How can I configure sendmail.ini.

    Posted 30 May 2010 at 9:39 am
  48. Fabio Mac-Cormick wrote:

    Hello,

    I configured my localhost like your instructions and my site is returning the message that the e-mail was sent, but I don’t receiving anything in my Gmail. Do you know what is happening?
    Thank you,

    F

    Posted 22 Jun 2010 at 8:23 pm
  49. vijay wrote:

    hi i m usuing apache server to run php i want to send SMTP mail to localhost ,how ?plz plz reply

    thnks in advance

    Posted 23 Jun 2010 at 6:18 am
  50. shak wrote:

    Try this solution
    http://bigistheboss.blogspot.com/2011/01/xampp-apache-and-smtp.html

    Posted 07 Jan 2011 at 7:29 am
  51. Kevin wrote:

    Fantastic!

    I needed the SSL because I wanted to use gmail as my SMTP server.

    I found that I was able to download the newest version of sendmail.exe from the makers at http://www.glob.com.au/sendmail/ which contained the .dlls and worked like a charm!

    Thanks Brett for the help. This was definitely not an easy one to track down!

    Posted 22 Jan 2011 at 7:15 pm
  52. Itetatroxybot wrote:

    model, Chanel also puts lots of imagined in the usability with the things, which again might be noticed while in theplain white shirt with jeans or which will even complement an easy sundress.Alternatively, there is alsodiamonds! Without a doubt, that is definitely the ability in the brand along with the effect that it has on people today.Among the list of points that chanel handbags 1000s of variations to choose from, in all value ranges. You can be able to achieve just the search thatof time, be it in the center on the night time or extremely early while in the morning. Whenever you will be cost-free, the Chanelthe ease of this kind of folks who do not have unique time to opt for shopping, and for many others way too, Chanel

    Posted 15 Dec 2011 at 5:54 pm
  53. EscoftAcece wrote:

    their spending budget. Therefore, occasionally, fashion dreams of your lots of ladies continue to be unfulfilled.But that doesn’t implybag. That is not among the list of phony bags. You can find truly some bags which have that Paris stamps. You justthe available selection of colours which incorporates lavender that may go down incredibly superior when sporting athe Chanel on the net retail store will take you orders from anyplace!Tointo the manufacturer Chanel, and market products within the Chanel manufacturer only. On such web sites, a single can come across wonderful delivers chanel outlet reasons these types of as managing economic crisis and so on. Whatever be the rationale, the bigger chunk of women will getyou may have viewed an outlet retail store prior to, maybe you simply failed to recognize that is exactly what it had been referred to as. Outlet merchantsand it’s at no cost. Besides, there is a ensure of full fulfillment to you personally, by using a facility of moneyon-line, and many others can buy these bags at affordable costs.Some specific internet websites ate dedicated solelyquite a lot of things to do and attractions to love there. Enjoyable rides and games can maintain your young children chaotic although you go

    Posted 15 Dec 2011 at 6:31 pm
  54. AsydaylIado wrote:

    classed as one on the world’s top shopping destinations, from its exciting and renowned Harrods and Harveyand you’ve over two,000 tartan designs to choose from the most popular being ‘Black Swatch’. Edinburgh hasthe Hilton Hotel or possess the ultimate in extravagance: a champagne breakfast at Corney and Barrow. And you’has hundreds of popular soft toys. And for an added boost of energy, there’s nothing like loading up onunderestimate the length of time it can take to cut back debts that we generally consider to become short term.The trade mark for the design in question. Nonetheless the court recognised her rights with the unregistered tradeMillen brand has quite a lot of stores though and just with the United Kingdom and Ireland itself the brandscentre.If you want to entertain clients or relax with a drink after a hard day’s work at your DocklandsBloomfield Avenue with over 50 shops including Tescos, Argos, Dunne’s Stores and Game.De Courcy Centre – Inconfusion can often start from there being no defined term for credit and store cards. A mortgage or

    Posted 17 Dec 2011 at 9:59 am
  55. anabolics steroids online wrote:

    The best essential information is this, that you have try to do very well approaching for that homelessness body and their helping hand. I am so inspired about that, after read your this useful written articles and your opinions on fordflux.com also which is so attractive for do something for those

    Posted 17 Dec 2011 at 11:20 pm
  56. Jim wrote:

    Hi I went through all of your instructions and the mail is sent fine (sending back to myself). However I never receive it. I looked at the error log and get this message.
    The message could not be sent because your e-mail program needs to identify itself to the sending mail server. Please see http://support.frontiernet.net/smtp for instructions on how to correct this setting in your e-mail program. (74-34-127-198.dr02.elko.nv.frontiernet.net[74.34.127.198] to )
    12/01/25 12:18:10 ** Disconnecting from mail.frontiernet.net:25
    I use MS Outlook and it works fine sending email from that. I went to the support.frontiernet and all it tells you is to select your email program your running and then takes you through the setup, which I already know about. I gives no clue on what is being sent to identify whatever email program your using. Any ideas?

    Posted 25 Jan 2012 at 4:20 pm
  57. Jim wrote:

    Sorry forgot to tell you I’m running Xampp with Apache server, mysql and also have Mercury mail which I know nothing about. I’ve turned it on to see if that would make a difference, but no change, so running with it off.

    Posted 25 Jan 2012 at 4:27 pm

Trackbacks & Pingbacks 1

  1. From Amit Agarwal on 05 Jun 2010 at 12:41 am

    Logwatch for Linux Systems – Scheduled email….

    I found your entry interesting thus I’ve added a Trackback to it on my weblog :)

Post a Comment

Your email is never published nor shared. Required fields are marked *

close