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

来源:3-17 邮件发送功能代码实现 mp4

慕移动0419469

2018-01-18

http://img.mukewang.com/szimg/5a60503d0001dcd409220514.jpg

http://img.mukewang.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回答

Jeson

2018-01-19

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

//img.mukewang.com/szimg/5a6159850001dd8705950239.jpg

//img.mukewang.com/szimg/5a6159860001ae7708910245.jpg


0
3
Jeson
回复
慕移动0419469
当然,这个错误是网易邮箱返回的错误提示
2018-01-20
共3条回复

Python+Django+Ansible Playbook自动化运维项目实战

【课程升级3.6版本】大牛全面践行DevOps,运维与开发间高效协作

861 学习 · 326 问题

查看课程