python中的服务器不支持SMTP AUTH扩展

时间:2016-09-25 11:07:24

标签: python python-2.7

我使用以下def根据状态发送电子邮件

def sendMail(fbase, status):
    server = smtplib.SMTP(config["global"]["smtp_server"], config["global"]["smtp_port"])
    server.login(config["global"]["smtp_user"],config["global"]["smtp_pass"])
    server.ehlo()
    server.starttls()
    from_addr = config["global"]["smtp_from"]
    if status == "Success":
        subject = "%s Uploaded sucessfully" % fbase
        msg = "\nHi,\n Video file - %s - uploaded successfully \n Thanks \n  Online Team" % fbase
        to_addr_list = config["global"]["smtp_to_success"]
    else:
        subject = "%s Failed to upload" % fbase
        msg = "\n Hi!\n Failed to upload %s \n Please check the log file immediatly \n Thanks" % fbase
        to_addr_list = config["global"]["smtp_to_failed"]

    header = 'From: %s\n' % from_addr
    header += 'To: %s\n' % ','.join(to_addr_list)
    header += 'Subject: %s\n\n' % subject
    message = header + msg
    server.sendmail(from_addr, to_addr_list, message)
    server.quit()
    logger.info("Mail send for status: %s" %(status))

广告管理员升级交换后,我开始收到以下错误

    raise ("SMTP AUTH extension not supported by server.")
SMTPException: SMTP ASMTPExceptionUTH extension not supported by server.

我添加了

server.ehlo()
server.starttls()

仍然得到同样的错误,

任何建议

1 个答案:

答案 0 :(得分:1)

在启动TLS之后执行登录步骤

def sendMail(fbase, status):
    server = smtplib.SMTP(config["global"]["smtp_server"], config["global"]["smtp_port"])

    server.ehlo()
    server.starttls()

    server.login(config["global"]["smtp_user"],config["global"]["smtp_pass"])
    ....