How to Route Emails via Different SMTP Connections in WordPress (Using FluentSMTP)

November 11, 2025

Solving the EmailIt hotmail delivery problem

If you manage multiple email delivery services, you might want WordPress to use one SMTP provider for certain recipients (e.g. Microsoft addresses like @hotmail.com) and another provider for everyone else.

This can improve deliverability, reputation management, and success rates when sending to tricky domains. In particular, this method has been put together to address delivery issues with Microsoft's free email services, such as hotmail.com and live.com, that EmailIt continues to suffer from.

Fortunately, this can be done neatly in WordPress using FluentSMTP and a few lines of PHP.

Why You Might Need This

Some email hosts handle certain destinations better than others. For example:

  • Hotmail/Outlook users often have strict spam filtering.
  • Transactional providers like Amazon SES may work better for general domains.
  • You might want all messages to corporate addresses to go via Microsoft 365 and others via SendGrid.

FluentSMTP already supports multiple SMTP connections — it simply chooses one based on the “From” email address. With a short code snippet, you can automatically switch that “From” address depending on the recipient domain.

Step 1 – Set Up Two FluentSMTP Connections

Go to Settings → FluentSMTP → Settings and create two connections:

Primary connection (default)

  • From Email: [email protected]
  • Provider: your main SMTP (e.g. Amazon SES, MailGun, SendGrid)
  • Mark as Default Connection

Secondary connection (for Microsoft addresses)

  • From Email: [email protected] (or any other alias you prefer)
  • Provider: the SMTP you want to use for Hotmail/Outlook/Live addresses

For my use case, my primary connection is with MailGun and the secondary with EmailIt.

FluentSMTP automatically chooses the connection based on the “From” address.
The code below will change that address dynamically depending on the recipient.

Step 2 – Add the Routing Snippet

Add this snippet to your site using a code snippets plugin, a custom plugin, or your theme’s functions.php.

/**
 * Route emails through different FluentSMTP connections depending on the recipient domain.
 *
 * Requires:
 * - Primary FluentSMTP connection (default): e.g. [email protected]
 * - Secondary FluentSMTP connection: e.g. [email protected]
 *
 * Adjust the domain lists and email addresses as needed.
 */
add_action( 'phpmailer_init', function ( $phpmailer ) {
    if ( ! $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) {
        return;
    }

    // Combine all recipient types (To, CC, BCC)
    $recipients = array_merge(
        (array) $phpmailer->getToAddresses(),
        (array) $phpmailer->getCcAddresses(),
        (array) $phpmailer->getBccAddresses()
    );

    if ( empty( $recipients ) ) {
        return;
    }

    // Define which recipient domains should trigger the secondary route
    $special_domains = [
        'hotmail.com',
        'hotmail.co.uk',
        'outlook.com',
        'outlook.co.uk',
        'live.com',
        'live.co.uk',
        // Add more domains here if needed
    ];

    $use_secondary = false;

    foreach ( $recipients as $recipient ) {
        $email = isset( $recipient[0] ) ? strtolower( trim( $recipient[0] ) ) : '';
        if ( ! $email || strpos( $email, '@' ) === false ) {
            continue;
        }

        $domain = substr( strrchr( $email, '@' ), 1 );

        if ( in_array( $domain, $special_domains, true ) ) {
            $use_secondary = true;
            break;
        }
    }

    if ( ! $use_secondary ) {
        return; // send normally
    }

    // Switch the "From" to match the secondary FluentSMTP connection
    $from_email = '[email protected]'; // secondary connection
    $from_name  = get_bloginfo( 'name' );

    $phpmailer->setFrom( $from_email, $from_name, false );
    $phpmailer->Sender = $from_email; // optional but recommended
}, 5 );

How It Works

  1. WordPress uses PHPMailer to send emails.
  2. FluentSMTP hooks into PHPMailer and chooses which SMTP connection to use based on the From address.
  3. The snippet above runs before FluentSMTP and updates the From address if any recipient matches the domains in your list.
  4. FluentSMTP sees the new From address and automatically routes the email through the corresponding SMTP connection.

Step 3 – Test the Routing

  1. Send a test email from WooCommerce or a form plugin to a non-Microsoft address (e.g. Gmail).
    → It should send via your primary connection.
  2. Send a test to a Hotmail or Outlook address.
    → It should now show as sent via your secondary connection in the FluentSMTP Email Logs.

If you use both providers’ dashboards, you’ll also see the messages arriving through the expected route.

Notes & Tips

  • If an email goes to both Hotmail and non-Hotmail recipients in the same send, the entire message will use the secondary connection.
  • You can expand the $special_domains array with any domain list you like.
  • Works seamlessly with WooCommerce, Gravity Forms, Fluent Forms, and most plugins using WordPress’s wp_mail() function.
  • Keep the hook priority at 5 to ensure it runs before FluentSMTP’s internal routing.

In Summary

By combining FluentSMTP’s multi-connection feature with a simple PHPMailer hook, you can intelligently route WordPress emails based on the recipient domain — no extra plugin or service required.

It’s a lightweight, flexible way to:

  • Improve deliverability to specific providers
  • Separate transactional and marketing traffic
  • Control which SMTP handles which type of email
crossmenu
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram