How to use Mercury Mail in XAMPP


When you try to use the mail() PHP function in your local computer, you get this message:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom 
"From:" header missing in C:\xampp\htdocs\test.php on line 14

Fortunately, I found a solution. In this tutorial I will show you how you can be able to use mail() function in your local computer with the help of Mozilla Thunderbird so you’ll know if your mail script really does work. In your XAMPP package, there’s a tool there called Mercury Mail. This app can, sort of, imitate an email provider like Gmail, Yahoo Mail, or others. But to set it up is a little bit tricky, took me hours to get it to work so I’d like to share this with you guys to save you time and frustration. :)

In case you’re wondering what Mercury Mail looks like or where to find it, here’s a snap shot:

Like for Apache and MySQL just hit Start to activate it and wait for Running to show. Then the Mercury Mail window pops up:

I started by creating a new user. Go to Configuration Manage local users then Add. I put in the following:

Username: username
Personal Name: personalname@localhost
Mail Password:[same password you'll enter in thunderbird]

After entering all 3 info in User details window, click OK.

Then in Thunderbird, I created an account using the following credentials:

 Your name: username
 Email Address: username@localhost
 password:[password set up in mercury mail]
 Server Type: POP3

Click Create Account.

Remember that error in the beginning? To get rid of it, I edited my php.ini file, search for sendmail_from and removed the semi-column (;) so that line isn’t a comment anymore (didn’t change the value).

;sendmail_from = postmaster@localhost

That’s it! But for this to work you have to restart your XAMPP. Once they’re back on (Apache, MySQL, and Mercury Mail) run your PHP script, this is how mine looks like:

<?php
 $recipient="username@localhost";
 $subject="Test Email";
 $mail_body="Nobody is going to get this email but me.";
 mail($recipient, $subject, $mail_body);
 ?>

And this is the result:

I hope you enjoyed this tutorial. I’ll be back for more :)

About these ads

17 comments on “How to use Mercury Mail in XAMPP

  1. Thank you for the tutorial, yet I end up get an error, “Thunderbird fail to find the settings for your email accout”

    • You’re welcome. :)

      Can you retrace your steps? Maybe you missed one. Can you double check if you have the credentials you entered in Mercury Mail and Mozilla Thunderbird the same?

      Get back at me and I’ll try me best to help you.

      P.S. Sorry for the late reply. I’m busy nowadays but I can still find time to chime in.

      • With that, I still receive 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\website\Index_Public_Images\public_images.php on line 38

        [mail function]
        ; For Win32 only.
        ; http://php.net/smtp
        SMTP = localhost
        ; http://php.net/smtp-port
        smtp_port = 25

        ; For Win32 only.
        ; http://php.net/sendmail-from
        sendmail_from = postmaster@localhost

        ; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
        ; http://php.net/sendmail-path
        ;sendmail_path =

      • Sorry the error that I receive IS

        Warning: mail(): SMTP server response: 421 Service not available, closing channel. in C:\wamp\www\website\Index_Public_Images\public_images.php on line 38

        The other one was shown because I didn’t activated my mercury mail :D

      • Not sure if XAMPP and WAMP have their folder arrangements the same, or if they even have the same folders, but if they do, try to go to C:\wamp\mercurymail (or if you don’t have this, try to look for mercury mail’s folder), create a folder in there and call it “QUEUE”.

      • Man :’( Can you explain me what happened here, Before I say what I’ve done to make ppl who have the same problem ffix it,
        I copied the MercuryMail from XAMPP to WAMP and into both of them I put the folder as you said and named it QUEUE, and that worked like magic O.o
        Thanks a lot man <3 Both of guys from BIG forums couldn't fix this <3 thanks a lot :D I was stuck there Now I can finish learning :D thank you <3

  2. I searched the web. There’s a forum that mentioned the queue folder is missing in a version of XAMPP, and with this bug your error is produced.

    I’m happy I was able to help. :)

  3. I dunno how dumb i am but i just follow all the instructions provided below but still unable to receive the email i sent.

    There are no errors or whatsoever so what the hell is wrong? I honestly spent a good number of hours dealing with this stupidity of mine and still unable to formualte anything.

    My mail function configuration:

    [mail function]
    ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
    SMTP = localhost
    smtp_port = 25

    ; For Win32 only.
    ; http://php.net/sendmail-from
    sendmail_from = postmaster@localhost

    My php code (yours actually :) )
    :

    Plss help me :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s