This article will tackle a simple way to solve this issue using your own SMTP server. But to proceed, you must first know the SMTP server details of your web host. Most web hosting packages mostly includes php mailer which may already setup for you by your hosting provider. You may contact your web hosting provider for the SMTP server details if ever you do not know.

Now, open wp-config.php file (located at the root of your website) using text editor and paste the following codes right below the database constant:

define('SMTP_USER',   'your email');    		// Username to use for SMTP authentication
define('SMTP_PASS',   'your password');       	// Password to use for SMTP authentication
define('SMTP_HOST',   'your host');    			// The hostname of the mail server (usually your domain)
define('SMTP_FROM',   'from email address');	// SMTP From email address
define('SMTP_NAME',   'from name');    			// SMTP From name
define('SMTP_PORT',   '465');					// SMTP port number - likely to be 25, 465 or 587
define('SMTP_SECURE', 'ssl');					// Encryption system to use - ssl or tls
define('SMTP_AUTH',    true);					// Use SMTP authentication (true|false)

This code may also be put in the function.php file of your theme but for security reasons I prefer to put it in the wp-config.php file. After setting up the constant definition above, open function.php file located at your WordPress theme directory and paste the following codes:

add_action('phpmailer_init', 'reyborn_send_smtp_email');
function reyborn_send_smtp_email( $mailer ) {
	$mailer->isSMTP();
	$mailer->Host       = SMTP_HOST;
	$mailer->SMTPAuth   = SMTP_AUTH;
	$mailer->Port       = SMTP_PORT;
	$mailer->Username   = SMTP_USER;
	$mailer->Password   = SMTP_PASS;
	$mailer->SMTPSecure = SMTP_SECURE;
	$mailer->From       = SMTP_FROM;
	$mailer->FromName   = SMTP_NAME;
}

This will tell WordPress to use the above SMTP configuration when evoking wp_mail function to send the email.

That’s all folks, I hope it helps. Please rate below if you find this post helpful.
Happy coding!

 

Disclosure: Some of the links in this post are "affiliate links". We may receive a commission for purchases made through these links.

Leave a Reply

RATE THIS POST*

Your email address will not be published. Required fields are marked *