Basic Configuration
Refer to the documentation in the Django doc: Send mail
- Configure the following configuration in Settings:
‘smtp.163.com‘‘25‘‘[email protected]‘‘******‘ # 填密码
- Then call Send_mail to send the message
u‘号码通激活‘ print name u‘用户:‘u‘ 您好,首先非常感谢你的注册‘ u"\n点击链接就可以激活邮箱,从而用邮箱进行登陆:" u"http://192.168.1.163:8080/account/activate/?activation_key=" + activation_key u"\n我们将为你提供非常好的号码相关服务:比如号码备份/群组建立/号码查找/群组活动等等,来自108网络教研室" print message send_mail(subject, message, settings.EMAIL_HOST_USER, [dst_email])
Question one: System return letter
When sending the mail, encountered the situation of the system return, later analysis found that because the Chinese characters are too few, the URL is too long, was filtered by the mail system, add some Chinese characters and content is good; or consider using a corporate mailbox
Issue two: Send mail times wrong
Smtpauthenticationerror at/account/Register/(550,' User has no permission ') Request Method:Postrequest url:http://192.168.1.163:8080/account/register/Django Version:1.7.1ExceptionType: Smtpauthenticationerrorexception Value: (550,' User has no permission ') Exception location:/usr/lib/python2.7/smtplib.pyinchLogin, line615Python executable:/usr/bin/pythonpython Version:2.7.6Python Path: ['/home/zy/code/python/app/git/app/webcode ','/usr/local/lib/python2.7/dist-packages/gitosis-0.2-py2.7.egg ','/usr/lib/python2.7/dist-packages ','/usr/lib/python2.7 ','/usr/lib/python2.7/plat-i386-linux-gnu ','/USR/LIB/PYTHON2.7/LIB-TK ','/usr/lib/python2.7/lib-old ','/usr/lib/python2.7/lib-dynload ','/home/zy/.local/lib/python2.7/site-packages ','/usr/local/lib/python2.7/dist-packages ','/usr/lib/python2.7/dist-packages/pilcompat ','/usr/lib/python2.7/dist-packages/gst-0.10 ','/usr/lib/python2.7/dist-packages/gtk-2.0 ','/usr/lib/python2.7/dist-packages/ubuntu-sso-client ']server Time:tue, -Apr - A: at: the+080
Workaround: Because the other project also uses the same method to send the message, and then test to send the message normally, troubleshoot the mail server problem. Then I think of the SMTP service opening problem of the mailbox. So, login mailbox, open the service is OK.
Two issues with Django sending mail