天天生鲜 smtplib.SMTPDataError: (554, b'DT:SPM 163 smtp13

问题描述

Python3.5 + Django2.2 天天生鲜项目在【3-07_django内置函数发送激活邮件】一节中填写完注册信息后提交时出现如下报错:

Internal Server Error: /user/register
Traceback (most recent call last):
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/fang/dailyfresh/apps/user/views.py", line 72, in post
    send_mail(subject, message, sender, receiver, html_message=html_message)
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/core/mail/__init__.py", line 60, in send_mail
    return mail.send()
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/core/mail/message.py", line 291, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 110, in send_messages
    sent = self._send(message)
  File "/home/fang/dailyfresh/venv/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 126, in _send
    self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
  File "/usr/lib/python3.5/smtplib.py", line 883, in sendmail
    raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (554, b'DT:SPM 163 smtp13,EcCowAD34gia_1RdzGE+IA--.15684S2 1565851546,please see http://mail.163.com/help/help_spam_16.htm?ip=223.93.186.229&hostid=smtp13&time=1565851546')

出错原因

554是邮件被网易默认为垃圾邮件,肯定是你发的邮件中有广告性信息,如:诚邀、免费注册之类的敏感词。当敏感词的比重达到一定数值时,就会被识别为垃圾邮件拒发。

解决方法

在收件人列表里面加上自己的邮箱

# 发邮件
subject = '天天生鲜欢迎信息'
message = ''
sender = settings.EMAIL_FROM
receiver = [email, sender]
html_message = '

%s,欢迎你成为天天生鲜注册会员。


请点击下面链接激活您的账户http://127.0.0.1:8000/user/active/%s' % (username, token, token) send_mail(subject, message, sender, receiver, html_message=html_message) ]

你可能感兴趣的:(Python3.5,Django2,激活邮件,天天生鲜,Django,Python3)