def login_oauth2(self, oauth2_file): self.smtp = smtplib.SMTP(self.host, self.port, **self.kwargs) self.smtp.set_debuglevel(self.debuglevel) oauth2_info = get_oauth2_info(oauth2_file) auth_string = get_oauth_string(self.user, oauth2_info) self.smtp.ehlo(oauth2_info["google_client_id"]) self.smtp.starttls() self.smtp.docmd('AUTH', 'XOAUTH2 ' + auth_string)
def get_oauth_string(user, oauth2_info): return get_oauth_string(user, oauth2_info)