TechBuzzPro

Send Email with XAMPP and Mercury32 in Windows

· 5 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can send emails from your XAMPP-powered PHP applications on Windows using Mercury32. Mercury32 is a free SMTP mail sending program that acts as an SMTP server, allowing PHP to send emails without relying on a traditional mail server. This guide provides a detailed, step-by-step process to set up Mercury32 and configure your PHP environment to utilize it.

What You'll Need

  • XAMPP installed (including Apache and PHP)
  • Mercury32 downloaded and installed (from )
  • A valid email account (Gmail, Outlook, etc.) to use as the sending account. Be aware that some providers require you to enable "less secure app access" or generate an app password, which we will cover.

Step-by-Step

  1. Download and Install Mercury32: Go to the Mercury32 website and download the latest version. Run the installer and follow the on-screen instructions. The default installation location is usually C:\Program Files (x86)\Mercury32, but note this down, as you may need it later.
  2. Configure Mercury32: After installation, launch Mercury32. The interface is straightforward. You'll need to configure the SMTP server details for your email provider.
    • Account Tab: Click the "Account" tab. Enter your full email address in the "From" field.
    • Server Tab: Click the "Server" tab. Enter the SMTP server address and port for your email provider. Here are some common examples:
      • Gmail: SMTP server: smtp.gmail.com, Port: 587, Security: TLS
      • Outlook/Hotmail: SMTP server: smtp-mail.outlook.com, Port: 587, Security: STARTTLS
      • Yahoo: SMTP server: smtp.mail.yahoo.com, Port: 587, Security: STARTTLS
      *Note: Port 465 with SSL is also sometimes used, but 587 with TLS/STARTTLS is generally recommended.*
    • Advanced Tab: Click the "Advanced" tab. Enter your email password in the "Password" field. If you are using Gmail or another provider with enhanced security, you may need to enable "less secure app access" in your account settings (not recommended), or generate an "app password" specifically for Mercury32 (recommended). An app password is a 16-digit password specifically for using apps and devices. See the Troubleshooting section below for more details.
  3. Start Mercury32: Ensure Mercury32 is running. A small Mercury32 icon will appear in your system tray (near the clock). If it's not running, double-click the Mercury32 icon on your desktop to start it.
  4. Configure PHP to Use Mercury32: Open your XAMPP control panel and start Apache. Now, you need to tell PHP to use Mercury32 as its SMTP server. There are two main ways to do this:
    • Using `php.ini` (Global Configuration): This affects all PHP scripts on your XAMPP installation.
      • Locate your `php.ini` file. The location is often displayed in the XAMPP control panel when Apache is running. Alternatively, you can find it by searching for `php.ini` in your file explorer.
      • Open `php.ini` in a text editor (like Notepad).
      • Find the line `;extension=openssl` and remove the semicolon (`;`) to uncomment it. This is essential for secure connections.
      • Add the following lines at the end of the file:
        
        extension=mercury32.dll
        [mail]
        SMTP=127.0.0.1
        port=587
        secure=TLS
        auth=LOGIN
        from="your_email@example.com"
        
        Replace your_email@example.com with your actual email address.
      • Save the `php.ini` file.
      • Restart Apache from the XAMPP control panel for the changes to take effect.
    • Using `mail.php` (Script-Specific Configuration): This allows you to configure email settings on a per-script basis. This method is less common but can be useful for testing. You would include the following code at the beginning of your PHP script:
      
      
              
      Replace your_email@example.com with your actual email address.
  5. Test Your Configuration: Create a simple PHP script (e.g., `test_mail.php`) with the following code:
    
    
        
    Replace recipient@example.com and your_email@example.com with your actual email addresses. Save the file in your XAMPP `htdocs` directory. Open the script in your browser (e.g., `http://localhost/test_mail.php`). If the email is sent successfully, you should see "Email sent successfully!" in your browser.

Common Mistakes

  • Incorrect SMTP Server Details: Double-check the SMTP server address, port, and security settings for your email provider.
  • Firewall Issues: Ensure your firewall is not blocking Mercury32's connection to the SMTP server.
  • Incorrect Password: Verify that you have entered the correct password for your email account. If using Gmail or similar, make sure you've enabled "less secure app access" or generated an app password.
  • Missing `openssl` Extension: The `openssl` extension in PHP is required for secure connections (TLS/SSL). Ensure it is enabled in your `php.ini` file.
  • Incorrect `php.ini` Path: Ensure you are editing the correct `php.ini` file (the one used by your Apache server).

Tips

  • Use App Passwords: For Gmail, Outlook, and other providers with strong security, generate an app password instead of using your regular account password. This is more secure.
  • Check Mercury32 Logs: Mercury32 has a log file that can provide valuable information about any errors. You can access it from the Mercury32 interface.
  • Test with a Simple Script: Start with a very simple PHP script to isolate any configuration issues.
  • Verify Email Headers: When you receive the test email, check the email headers to ensure that the "From" address is correct and that the email is not being marked as spam.

Troubleshooting

  • Email Not Sending, No Error Message:
    • Check Mercury32 is running.
    • Verify SMTP server details and password are correct.
    • Check firewall settings.
  • "Failed to connect to SMTP server" Error:
    • Check your internet connection.
    • Verify the SMTP server address and port are correct.
    • Try a different port (e.g., 465 with SSL).
  • "Authentication failed" Error:
    • Double-check your password.
    • If using Gmail, Outlook, or Yahoo, enable "less secure app access" (not recommended) or generate an app password.
  • Gmail App Password Setup:
    • Go to your Google Account security settings.
    • Enable 2-Step Verification if you haven't already.
    • Under "Signing in to Google," select "App passwords."
    • Select "Mail" as the app and "Other (Custom name)" as the device.
    • Enter a name like "Mercury32" and click "Generate."
    • Copy the generated app password and use it in Mercury32's "Password" field.
  • Restart Everything: If you're still having problems, try restarting Mercury32, Apache, and your computer.

Frequently Asked Questions

Can I use Mercury32 with Gmail?

Yes, you can use Mercury32 with Gmail, but you'll likely need to generate an app password due to Gmail's security measures.

Is Mercury32 free for commercial use?

Yes, Mercury32 is free for both personal and commercial use.

Why do I need Mercury32 if I have XAMPP?

XAMPP provides the web server (Apache) and PHP interpreter, but it doesn't include a built-in mail sending facility. Mercury32 acts as an SMTP server, allowing PHP to send emails.

What is the difference between TLS and SSL?

TLS (Transport Layer Security) is the successor to SSL (Secure Sockets Layer). Both provide encryption for secure communication, but TLS is the more modern and secure protocol.

How do I know if my email was sent successfully?

Check your email inbox (and spam folder) for the test email. Also, review the output of your PHP script – it should display "Email sent successfully!" if the email was sent without errors.