Cant send email via python using gmail - smtplib.SMTPException: SMTP AUTH extension not supported by server

前端 未结 2 1412
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 09:49

I just want to send an email in python with an attachment

import smtplib, os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
fr         


        
相关标签:
2条回答
  • 2021-02-01 10:31

    On gmail you also have to give a smtp.ehlo() before smtp.starttls() This is also duplicate of How to send an email with Gmail as provider using Python?

    0 讨论(0)
  • 2021-02-01 10:50

    You need a call to starttls() before you login:

    smtp = smtplib.SMTP('smtp.gmail.com:587')
    smtp.starttls()
    smtp.login('fu@gmail.com', 'fu')
    

    Also, your send_from should be a str, not a list:

    send_from='fu@gmail.com'
    

    Note that smtp.starttls() calls smtp.ehlo() implicitly:

    If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. https://docs.python.org/2/library/smtplib.html#smtplib.SMTP.starttls

    0 讨论(0)
提交回复
热议问题