Skip to content

Instantly share code, notes, and snippets.

@hamedmoody
Created September 5, 2019 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamedmoody/2f6f7512a5baac7b4730486bb1c57ffe to your computer and use it in GitHub Desktop.
Save hamedmoody/2f6f7512a5baac7b4730486bb1c57ffe to your computer and use it in GitHub Desktop.
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) PHPMailer SMTP Settings
* Description: Enables SMTP servers, SSL/TSL authentication and SMTP settings.
* Allow less secure apps in: https://myaccount.google.com/u/2/lesssecureapps?pageId=none
*/
add_action( 'phpmailer_init', 'phpmailerSMTP' );
function phpmailerSMTP( $mail )
{
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "xxx@gmail.com";
//Password to use for SMTP authentication
$mail->Password = "xxx";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment