smtplib.SMTPException: SMTP AUTH extension not supported by server

刘超 11天前 ⋅ 88 阅读   编辑

一、描述

  python发送邮件报如下错误

sdev@n-adx-hadoop-client-3:~/liujichao/py_lib$ python email_util.py 
Traceback (most recent call last):
  File "email_util.py", line 104, in 
    em_obj.send()
  File "email_util.py", line 97, in send
    smtp.login(username, password)
  File "/usr/lib/python2.7/smtplib.py", line 585, in login
    raise SMTPException("SMTP AUTH extension not supported by server.")
smtplib.SMTPException: SMTP AUTH extension not supported by server.

二、分析

  1、设置smtp.set_debuglevel(1),打印出和SMTP服务器交互的所有信息,如下

sdev@n-adx-hadoop-client-3:~/liujichao/py_lib$ python email_util.py 
send: 'ehlo [172.17.67.0]\r\n'
reply: '250-smtp.gmail.com at your service, [82.145.215.174]\r\n'
reply: '250-SIZE 35882577\r\n'
reply: '250-8BITMIME\r\n'
reply: '250-STARTTLS\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-CHUNKING\r\n'
reply: '250 SMTPUTF8\r\n'
reply: retcode (250); Msg: smtp.gmail.com at your service, [82.145.215.174]
SIZE 35882577
8BITMIME
STARTTLS
ENHANCEDSTATUSCODES
PIPELINING
CHUNKING
SMTPUTF8
Traceback (most recent call last):
  File "email_util.py", line 104, in <module>
    em_obj.send()
  File "email_util.py", line 97, in send
    smtp.login(username, password)
  File "/usr/lib/python2.7/smtplib.py", line 585, in login
    raise SMTPException("SMTP AUTH extension not supported by server.")
smtplib.SMTPException: SMTP AUTH extension not supported by server.

  啥也没看出

  2、翻看google帮助文档,使用SMTP发邮件需要ssl,需要使用smtplib.SMTP_SSL(host,sslPort)

三、解决方法

  使用smtplib.SMTP_SSL(host,sslPort)  


注意:本文归作者所有,未经作者允许,不得转载

全部评论: 0

    我有话说: