SMTP AUTH extension not supported by server in python 2.4

前端 未结 2 520
無奈伤痛
無奈伤痛 2021-02-05 15:42

This is my normal code in my VPS hosting which provide python 2.4

def mail(receiver,Message):
    import smtplib
    try:
        s=smtplib.SMTP()
        s.con         


        
相关标签:
2条回答
  • 2021-02-05 15:56

    Is SMTP.starttls() available? You can also do e.g.:

    def mail(receiver,Message):
        import smtplib
        try:
            s=smtplib.SMTP()
            s.connect("smtp.gmail.com",587)
            s.starttls()
            s.login("email@gmail.com", "password")
            s.sendmail("email@gmail.com", receiver, Message)
        except Exception,R:
                return R
    
    0 讨论(0)
  • 2021-02-05 16:13

    Guys thanks i've found the solution and this is the solution =)

    def mail(receiver,Message):
        import smtplib
        try:
            s=smtplib.SMTP()
            s.connect("smtp.gmail.com",465)
            s.ehlo()
            s.starttls()
            s.ehlo()
            s.login("email@gmail.com", "password")
            s.sendmail("email@gmail.com", receiver, Message)
        except Exception,R:
                return R
    
    0 讨论(0)
提交回复
热议问题