请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

发送邮件测试时,认证失败

https://img1.sycdn.imooc.com//szimg/5a60503d0001dcd409220514.jpg

https://img1.sycdn.imooc.com//szimg/5a60503d00019e3106160595.jpg

执行返回结果信息:

In [16]: from django.core.mail import send_mail


In [17]: send_mail('Mydevops email','This is a test','sharkyun2017@126.com',['dockerhub@163.com'],fail_silently=False)

---------------------------------------------------------------------------

SMTPAuthenticationError                   Traceback (most recent call last)

<ipython-input-17-61d83710df4f> in <module>()

----> 1 send_mail('Mydevops email','This is a test','sharkyun2017@126.com',['dockerhub@163.com'],fail_silently=False)


/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/__init__.pyc in send_mail(subject, message, from_email, recipient_list, fail_silently, auth_user, auth_password, connection, html_message)

     60         mail.attach_alternative(html_message, 'text/html')

     61 

---> 62     return mail.send()

     63 

     64 


/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/message.pyc in send(self, fail_silently)

    301             # send to.

    302             return 0

--> 303         return self.get_connection(fail_silently).send_messages([self])

    304 

    305     def attach(self, filename=None, content=None, mimetype=None):


/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.pyc in send_messages(self, email_messages)

     98             return

     99         with self._lock:

--> 100             new_conn_created = self.open()

    101             if not self.connection:

    102                 # We failed silently on open().


/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.pyc in open(self)

     65                 self.connection.ehlo()

     66             if self.username and self.password:

---> 67                 self.connection.login(self.username, self.password)

     68             return True

     69         except smtplib.SMTPException:


/usr/lib64/python2.7/smtplib.pyc in login(self, user, password)

    619             # 235 == 'Authentication successful'

    620             # 503 == 'Error: already authenticated'

--> 621             raise SMTPAuthenticationError(code, resp)

    622         return (code, resp)

    623 


SMTPAuthenticationError: (535, 'Error: authentication failed')


正在回答

1回答

       看你发送邮件方法send_mail() 需要from_email和settings配置文件中的邮箱Email_Host_User不一样,需要一致

//img1.sycdn.imooc.com//szimg/5a6159850001dd8705950239.jpg

//img1.sycdn.imooc.com//szimg/5a6159860001ae7708910245.jpg


0 回复 有任何疑惑可以回复我~
  • 提问者 慕移动0419469 #1
    非常感谢老师 的回答!
    回复 有任何疑惑可以回复我~ 2018-01-20 07:15:13
  • 提问者 慕移动0419469 #2
    我修改过后,发送成功了,但是有个问题,就是我的收件人和发件人都是同一个地址可以成功,都是126 邮箱。
    当我的收件人是163邮箱的情况下,就不能成功了,抛出了异常: 
    SMTPDataError: (554, 'DT:SPM 126 smtp7,DsmowAAHctJGCWJaT_7xAw--.20779S2 1516374343,please see http://mail.163.com/help/help_spam_16.htm?ip=218.241.251.129&hostid=smtp7&time=1516374343')
    回复 有任何疑惑可以回复我~ 2018-01-20 07:18:37
  • Jeson 回复 提问者 慕移动0419469 #3
    当然,这个错误是网易邮箱返回的错误提示
    回复 有任何疑惑可以回复我~ 2018-01-20 08:41:37
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信