Method #1: Using a third-party plugin
There are many WordPress plugins that provide e-mail functionality. One of the most popular and well-known plugins is WP Mail SMTP, which enables you to configure e-mail settings that are compatible with hosting.com servers.Installing the WP Mail SMTP plugin
To install the WP Mail SMTP plugin, follow these steps:- Log in to your WordPress site as the administrator.
- In the left-hand pane, click Plugins.
- Click Add New.
-
In the Search Plugins text box, type
mail smtp, and then press Enter. - Locate WP Mail SMTP by WPForms, and then click Install Now.
- After WordPress finishes installing the plugin, click Activate.
Configuring the WP Mail SMTP plugin
To configure the WP Mail SMTP plugin to work with your account, follow these steps:- Log in to your WordPress site as the administrator.
- In the left-hand pane, click WP Mail SMTP, and then click Settings. The WP Mail SMTP general settings page appears.
-
Under Mail, in the From Email text box, type the e-mail address you want to use as the sender.
🚧 Important This e-mail address must exist on your account.
- In the From Name text box, type the name you want to associate with the e-mail address you specified in step 3.
- Under Return Path, select the Set the return-path to match the From Email check box.
- Under Mailer, select Other SMTP.
-
Under Other SMTP, in the SMTP Host text box, type the full server name for your account.
📘 Note For information about how to determine your account’s server name, please see this article.
- Choose one of the following configurations:
-
If you want to use encryption, in the SMTP Port text box type
465, and then under Encryption, select SSL. -
If you do not want to use encryption, in the SMTP Port text box type
25, and then under Encryption, select None.
hosting.com strongly recommends you use encryption whenever possible.
- Under Authentication, select On.
- In the SMTP Username text box, type the e-mail address you specified in step 3.
- In the SMTP Password text box, type the password for the e-mail account you specified in step 10.
- Click Save Settings.
Method #2: Using the WordPress API
Instead of using a third-party plugin to handle e-mail for your site, you can develop your own custom code and use the wp_mail() function in the WordPress API.The following procedure demonstrates how to send e-mail messages using SMTP authentication. The broader topic of how to write a plugin is beyond the scope of this article. For information about how to get started writing a WordPress plugin, please visit https://developer.wordpress.org/plugins.
- In the wp-config.php file, copy and paste the following code:
- Replace the SMTP_HOST, SMTP_USERNAME, SMTP_FROM, and SMTP_FROMNAME values with the settings for your own site, and then save your changes to the wp-config.php file.
- In your plugin code file, copy and paste the following code:
- To send an e-mail message, call the wp_mail() function. For example: