Fall Sale: Save $60 Today!

Your WordPress contact form is not sending emails? Here’s how to fix it.

4 minute read

How useful is a contact form if you can’t get messages to reach your inbox? Unfortunately, this is a common issue and one that can cost you precious leads.

In this article, we’ll recap how WordPress sends emails, why it sometimes fails to do so, and the possible solutions.

Do you get an email address with WordPress?

If it’s your first time using WordPress, you might ask yourself whether or not WordPress comes with an email address. The answer is no, WordPress doesn’t offer an email address. So how is it able to send emails at all?

The answer might surprise you: WordPress doesn’t need an email address to send emails. If your hosting provider hasn’t disabled it, your server includes a utility to send emails without an actual email account: that’s what WordPress will use to send emails too, out of the box.

Emails not sending, or ending in spam?

As we mentioned, WordPress uses your server’s email utility to send emails. It does so through PHP’s mail() function, which is pretty powerful on paper: you can send email to anyone, and you’re free to specify whatever “from” address you like.

This power makes it the perfect tool for spammers — in fact, it was a common way of sending spam in the past. This makes major email providers like Gmail suspicious of WordPress emails, and that’s the reason why all of them have filters in place to make sure emails sent this way either land in spam or never reach their destination.

So here you have it: you’re being punished because you might be a spammer. You’re not, obviously, but there is no way for an email provider to tell you apart from the bad guys. So what’s the solution? SMTP to the rescue.

What is SMTP?

SMTP is an internet protocol for sending emails. You surely know at least another internet protocol, HTTP, whose purpose is to exchange data across the web — for example, a browser that visits a web page.

SMTP offers a fundamental advantage over the default email system of your server: emails you send through it can be traced back to a real organization (the email provider) and person (the user account who sent the email). When email providers like Gmail receive your email, they can verify its authenticity and have no issues delivering it to its recipient.

How to setup SMTP in WordPress

The first thing you need is, obviously, an SMTP account. When you register for an email address, you’re actually registering for an SMTP account with your email provider (like Gmail). If you use the email provider’s web interface, you’ll never need to tinker with your SMTP credentials — but if you decide to use a dedicated application, like Microsoft Outlook or Apple Mail, you’ll notice you need to fill in those credentials so that your client can connect to your SMTP account. The same happens in WordPress.

Once you obtained your credentials, you’re finally ready to add SMTP to your WordPress site. We’ll explore 2 different ways to do so.

Option 1: use a WordPress SMTP plugin

When it comes to SMTP plugins, there’s plenty of alternatives to choose from. So many in fact, that choosing one isn’t an easy task. We’ll share a few suggestions to help you make the right pick:

  1. Using Gmail? You might want to look into a dedicated plugin like Gmail SMTP. Otherwise, both Easy WP SMTP and WP Mail SMTP support Gmail.
  2. Using a transaction email delivery service like Sendinblue, SendGrid, Mailgun or MailerSend? First look for dedicated plugins: Mailin for Sendinblue, Mailgun for WordPress for Mailgun, MailerSend for MailerSend. SendGrid doesn’t offer a dedicated plugin at the time of writing, but some alternatives support it, like WP Mail SMTP and Post SMTP Mailer.
  3. Using another SMTP provider? Just go with WP Mail SMTP or Post SMTP Mailer.

Option 2: WordPress SMTP without a plugin

In our experience, a SMTP plugin is the best choice as it takes care of all the sneaky details — and believe us, there’s a lot of them. SMTP can still fail for a number of reason, and SMTP services evolve all the time. If your SMTP plugin is actively maintained, you won’t need to keep up with all these nuisances.

Still, if you’d rather avoid installing a plugin and opt for a leaner approach, you can configure SMTP with a bit of custom code. It’s surprisingly simple, just add this code to your functions.php file:

add_action( 'phpmailer_init', function( $mailer ) {
    $mailer->IsSMTP();
    $mailer->setFrom( SMTP_FROM_ADDRESS, SMTP_FROM_NAME );
    $mailer->Username = SMTP_USER;
    $mailer->Password = SMTP_PASSWORD;
    $mailer->Host = SMTP_HOST;
    $mailer->Port = SMTP_PORT;
    $mailer->SMTPAuth = true;
    $mailer->SMTPSecure = 'tls';
} );

Make sure to replace these with the actual SMTP credentials provided by your email service:

SMTP_FROM_ADDRESS: Your email address.
SMTP_FROM_NAME: The name that appears in the recipient’s email client. You’re free to pick anything you like.
SMTP_USER: Your SMTP user name.
SMTP_PASSWORD: Your SMTP password.
SMTP_HOST: Your SMTP server address (e.g. smtp.gmail.com)
SMTP_PORT: Your SMTP port (e.g. 25 or 587)

That’s all! The suggestions above should help you get SMTP up and running, and sort out any email delivery issues for good.

Build your high-conversion WordPress forms

Take a look at our three different plans and learn how Happyforms can help you get the most out of all of your WordPress website traffic today.

Discover Happyforms for WordPress