Using SMTP to send emails from WordPress

By default email from your WordPress site will be sent using PHPmail by your hosting server. In theory this is quick and requires no setup from you. However, emails sent this way are not 'authenticated' - see our guide on mail authentication - SPF, DKIM and DMARC.

This lack of authentication may mean your emails will be blocked before they reach their intended recipient.

The way around this is to use SMTP mail. In WordPress this is accomplished by the use of a plugin. We suggest WP Mail SMTP (external link opens in a new window).

You'll need to be logged in to WordPress as an Administrator, or have sufficient privileges to be able to install a plugin.

You will need the login and configuration details of a cPanel mailbox to use in the following guide - this will ultimately be where your emails will be sent from. If you don't have those you can either find the configuration details for an existing mail account or create a new account.

  1. From the WordPress dashboard, select Plugins > Add New or from the Plugins screen click the Add New button.
  2. Start typing wp mail smtp into the search box and the correct plugin should show up in the results.
    Click the Install Now button.
  3. Once the plugin has installed click the Activate button.
  4. Access the settings for the plugin - either via the left hand menu or by clicking the Settings link below the plugins name.
  5. On the General tab scroll down to the Mailer section and select Other SMTP.
  6. You'll see a section appear below now title Other SMTP.
    You'll need to enter the details for the mailbox you'd like to use to send emails.
    SMTP host: will be either mail.yourdomain or your hosting server's name
    Encryption: ideally set to TLS (or SSL)
    SMTP port: 587 (or 465 if using SSL)
    Authentication: On
    SMTP Username: the email address of the mailbox being used to send emails
    SMTP Password: the password of the mailbox being used to send emails
    Click Save Settings to save these details.
  7. Take note of the message about the password being stored in plain text.
    We'd suggest completing the next step of testing that the settings are all working. Then updating your wpconfig.php with these edits and then testing again to make sure everything has stayed working.
  8. Scroll to the top and click the Email Test tab.
    Enter an email address to Send To: and choose whether to send an HTML email or not.
    Click Send Email.
    If all is well you'll see a green success banner.
    If there are any problems you'll see a red banner detailing the problem. You'll need to fix this before returning here to test again.
  9. Now, edit your wpconfig.php file to include the password - add the following two lines
    define( 'WPMS_ON', true );
    define( 'WPMS_SMTP_PASS', 'your_password' );
    just above the line
    /* That's all, stop editing! Happy publishing. */ 
    Change your_password for your mailbox password.
  10. Once you've added those lines to wpconfig.php you should return to the General tab and remove the SMTP Password and click Save Settings.
    The field will now appear greyed out - but still show the password stars.
  11. Finally switch to the Email Test tab again and send another test email to confirm the details have been added to wpconfig.php correctly.

Any email sent from your WordPress site, including from contact form plugins will now be sent via authenticated SMTP email.

Please remember that your cPanel email accounts are not designed to be used for sending mass emails. Doing so breaches our Acceptable Use Policy. If you want to manage mass mailing lists and send mass emails we'd suggest looking at products like MailChimp, icontact or Constant Contact. These solutions will also enable you to demonstarte compliance with GDPR/privacy rules.


How did we do?


Powered by HelpDocs
© Krystal Hosting Ltd 2003–2019