This article describes how to configure WordPress to send e-mail messages using SMTP authentication. You can use a third-party WordPress plugin to do this, or you can write your own code in a custom WordPress 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 A2 Hosting servers.
To install the WP Mail SMTP plugin, follow these steps:
To configure the WP Mail SMTP plugin to work with your account, follow these steps:
Click
You should test the new configuration to make sure that it works. To do this, follow these steps:
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.
To send e-mail messages with SMTP authentication using the WordPress API, follow these steps:
define( 'SMTP_HOST', 'server.a2hosting.com' ); // A2 Hosting server name. For example, "a2ss10.a2hosting.com" define( 'SMTP_AUTH', true ); define( 'SMTP_PORT', '465' ); define( 'SMTP_SECURE', 'ssl' ); define( 'SMTP_USERNAME', '[email protected]' ); // Username for SMTP authentication define( 'SMTP_PASSWORD', 'password' ); // Password for SMTP authentication define( 'SMTP_FROM', '[email protected]' ); // SMTP From address define( 'SMTP_FROMNAME', 'Kelly Koe' ); // SMTP From name
In your plugin code file, copy and paste the following code:
add_action( 'phpmailer_init', 'send_smtp_email' ); function send_smtp_email( $phpmailer ) { $phpmailer->isSMTP(); $phpmailer->Host = SMTP_HOST; $phpmailer->SMTPAuth = SMTP_AUTH; $phpmailer->Port = SMTP_PORT; $phpmailer->SMTPSecure = SMTP_SECURE; $phpmailer->Username = SMTP_USERNAME; $phpmailer->Password = SMTP_PASSWORD; $phpmailer->From = SMTP_FROM; $phpmailer->FromName = SMTP_FROMNAME; }
To send an e-mail message, call the wp_mail() function. For example:
wp_mail("[email protected]", "Subject", "Message");
WordPress then sends the message using the SMTP authentication settings you defined above.
For more information about the WP-Mail-SMTP plugin, please visit https://wordpress.org/plugins/wp-mail-smtp.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.