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

前端 未结 2 1415
被撕碎了的回忆
被撕碎了的回忆 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: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

提交回复
热议问题