2016-09-25 76 views
0

我使用下面的DEF基於身份發送電子郵件服務器不支持,SMTP AUTH擴展在python

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

執行登錄步驟之後您已經啓動了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"]) 
    .... 
+0

我做到了,但仍然得到相同的錯誤,沒有運氣 – Jecki

+0

@Jecki:'starttls'是否成功返回?您是否嘗試過沒有身份驗證? – mhawke