Tutorial

WordPress SMTP Setup (Plugin & Code)

wp_mail() defaults to your host's mail() function, which most inboxes distrust by default. Here's the fix.

By the Sendcorex team·Updated Sep 21, 2026·6 min read

Why WordPress emails go missing

By default, wp_mail() uses PHP's mail() function, which sends through your hosting provider's mail server — usually unauthenticated and often already on a blocklist because it's shared across thousands of sites. Routing through a real SMTP relay fixes this immediately.

Option 1: A plugin (easiest)

Install a plugin like WP Mail SMTP or Post SMTP, then under its settings choose "Other SMTP" and enter:

FieldValue
SMTP Hostsmtp.sendcorex.com
EncryptionTLS
SMTP Port587
UsernameYour Sendcorex API key
PasswordYour Sendcorex API key

Send a test email from the plugin's settings page before relying on it for real traffic.

Option 2: Code, via functions.php

If you'd rather not add a plugin, hook into phpmailer_init:

add_action('phpmailer_init', function ($phpmailer) {
    $phpmailer->isSMTP();
    $phpmailer->Host = 'smtp.sendcorex.com';
    $phpmailer->SMTPAuth = true;
    $phpmailer->Port = 587;
    $phpmailer->SMTPSecure = 'tls';
    $phpmailer->Username = getenv('SENDCOREX_API_KEY');
    $phpmailer->Password = getenv('SENDCOREX_API_KEY');
    $phpmailer->setFrom('hello@yourdomain.com', get_bloginfo('name'));
});

Verify your domain, not just the SMTP credentials

Either method only helps if the sending domain has SPF, DKIM and DMARC published — otherwise you've swapped one unauthenticated sender for another.

Fix WordPress email in minutes

Verify your domain, grab an API key, and drop it into the plugin settings.

No credit card required