Code SMTP

Paste code to function.php in Child theme

// tu dong gui email
add_action( 'phpmailer_init', function( $phpmailer ) {
if ( !is_object( $phpmailer ) )
$phpmailer = (object) $phpmailer;
$phpmailer->Mailer = 'smtp';
$phpmailer->Host = 'smtp.gmail.com';
$phpmailer->SMTPAuth = 1;
$phpmailer->Port = 587;
$phpmailer->Username = 'Tài khoản';
$phpmailer->Password = 'Mật khẩu ứng dụng';
$phpmailer->SMTPSecure = 'TLS';
$phpmailer->From = 'Địa chỉ email gửi';
$phpmailer->FromName = 'Tên người gửi';
});
// ket thuc gui email tu dung

Take Google app password

Click to link below and login to your gmail https://myaccount.google.com/u/1/security

Choose 2-step verification
Click "Begin" & Enter you password if required
Enter your number phone, choose "Text messages" and "NEXT"

You will receive your code by SMS

Enter your code and NEXT
Now you will see App Passwrod display here

Click to App password and enter your email password again if required

Select "Other (Custom name)"
Enter any name you want to Create

Note: By the way, your email never in Spam. However Gmail limit allow us sending maximum 100 email/day, if exceed limit, them will sending after 24 hours.

Last updated