How to Use SMTP to Send WordPress Emails

WordPress uses mail function in PHP to send emails. Shared Hosting is when multiple websites share a large server. Many shared hosting providers do not have PHP function configured property, or they have it disabled entirely to avoid abuse. This will cause WordPress emails to not be delivered.

What is WooCommerce?

Using Email Accounts by Your Host

Most WordPress hosting providers will offer email services for each domain you host with them. This means you can create an email account that is the same as your site’s domain name.

First, you will create an email account. To do this you need to log into your hosting account.

Then you will go to the CPanel, which is the account management system. Some hosting providers will use other account management systems.

You then need to click on email accounts, under the mail section. There will then be a simple form which needs to be filled in with the required information to create the email account.

After doing this you are ready to use your email account in WordPress. But before you do that you need your SMTP Host for your email address, and SMTP Port for secure login. You can get this information from your hosting service provider. This information is usually located in the support section of your host’s website, if it can’t be found then you can contact the hosting support to request the information.

Using Your Branded Email Address in WordPress

You now need to install and activate a plugin called WP Mail SMTP. When it has been activated you should go to Setting and then Email, to configure the plugin settings. 

First you need to enter the email address that you have just created.

After that you can add a from name, which will be used as the sender name. If you do not add a from name then the plugin will use the default WordPress.

Next you need to choose the mailer. You need to click on the ‘Other SMTP’ option, and check the box next to ‘Return Path’ This option sets the return path to match the sender address. If it is not checked then bounced messages and non-delivery receipts will be lost.

After this SMTP options need to be set up. Enter your SMTP host and port. Typically the SMTP host is mail.yourdomainname.com and the port 465 is commonly used. You should check this information from your hosting provider. 

You also need to choose encryption. Most WordPress hosting providers support both SSL and TLS. 

After that turn authentication on, and provide your SMTP username and password. 

Click on the ‘save settings’ button to store any changes you have made. 

Testing SMTP Settings

Now that  WP Mail SMTP has been set up to send emails, it should be tested to check that everything works. Go to the plugin’s settings page, and click on the ‘Email Test’ tab.

You need to provide an email address where you would like to receive test email. This could possibly be a personal email, it just has to be a valid email address that you can access. After filling in the box click on ‘Send Email’ to continue. 

WP Mail SMTP will send that email address an email message using the settings that you set up earlier. You will see a success message when it is sent successfully.

Securing Your Email Password

The password that was set up earlier in the ‘Using Your Branded Email Address in WordPress’ section of this blog, is stored as plain text. This means that it is not safe. The WP Mail SMTP plugin has an option to make it secure.

To do this you need to need to add some code to the wp-config.php file. 

First you need to connect to your website using a FTP client, or a File Manager application in the cPanel. When you have connected, you will find your wp-config. php file in the root folder. 

You can edit this using a plain text editor, such as Notepad or TextEdit. 

Next find the line that says ‘That’s all, stop editing! Happy Blogging’. Then add this code just above it.

1.

2.

define( ‘WPMS_ON’, true );

define( ‘WPMS_SMTP_PASS’, ‘your_password’ );

Make sure to replace ‘your_passord’ with the password that you want to use. Then save and upload your wp-config. php file back to the server. 

You can then visit your WordPress admin area. Go to Settings then Wp Mail SMTP page. You will then be able to see that the password field is disabled. 

Troubleshooting WordPress Email errors

The most common reason for errors in sending emails using SMTP is having an incorrect SMTP host or a port. You need to make sure that you are entering the correct host and port settings. You can check these with your hosting provider.

Another reason for errors is choosing the wrong encryption method. SSL is usually the one that works best in most environments. If not, then you should check with your web host if your emails are not getting delivered.