Configuring SMTP Mail No Use For WordPress Plugin
This article will guide you to configure wordpress smtp mail without using any plugins . In the past I used config – smtp plugin , but in my plugin list , the plugin so much so I had to collapse the plugin , the plugin can be substituted by alternative code I have .
In wordpress there is a structural change action in wordpress mail that not everyone knows , there is action phpmailer_init , you copy and paste the following function into the functions.php file
//setting smtp for wordpress
add_action( 'phpmailer_init', 'configure_smtp' );
function configure_smtp( PHPMailer $phpmailer ){
$phpmailer->isSMTP(); //switch to smtp
$phpmailer->Host = 'mail';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 25;
$phpmailer->Username = 'info@abc.com.vn';
$phpmailer->Password = 'abc';
$phpmailer->SMTPSecure = false;
$phpmailer->From = 'info@bak.com.vn';
$phpmailer->FromName='abc.com.vn';
}
Here is the code under the account configured smtp mail on hosting , if you google mail contacts configured to be able to replace it with the following code :
//setting smtp for wordpress
add_action( 'phpmailer_init', 'configure_smtp' );
function configure_smtp( PHPMailer $phpmailer ){
$phpmailer->isSMTP(); //switch to smtp
$phpmailer->Host = 'mail.google.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 465;
$phpmailer->Username = 'abc@gmail.com';
$phpmailer->Password = 'abc';
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = 'abc@gmail.com';
$phpmailer->FromName='abc';
}
You test a try, can not successfully delivered ? Wish you enjoy this article for tips .