PHPMailer and OATH Support

Viewed 86

My question is simple... How do I pass in OAuth credentials, such as client ID, client secret, and refresh token to the built in PHPMailer supplied by WordPress. I'm assuming it has to be done via the functions.php folder but I am unsure. An example of what the add_action might look like is below. I cant find any information on how to pass the OAuth credentials anywhere.

function send_smpt_email($mailer) {                                
   $mailer->isSMTP();                                            
   $mailer->SMTPDebug  = SMTP::DEBUG_SERVER;                                      
   $mailer->Host       = 'smtp.gmail.com';                           
   $mailer->Port       = 587;
   $mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         
   $mailer->SMTPAuth   = true;                                   
   $mailer->AuthType   = 'XOAUTH2';
   $mailer->ClientId   = 'Client ID'; 
   $mailer->ClientSecret = 'Client Secret';
   $mailer->RefreshToken = 'Refresh Token';
}
add_action('phpmailer_init', 'send_smpt_email');

Obviously, this isn't how it is done but my whole purpose here is to figure out how. This is simply to illustrate my question. Hopefully someone has figured this out and can help.

0 Answers
Related