由于永久性异常消息无法处理消息无法提交消息Django Outlook / hotmail

问题描述 投票:2回答:1

如果有人遇到这个问题,我将非常感谢你的帮助。

我在发送带有hotmail的本地电子邮件时遇到此错误:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/huey/consumer.py", line 169, in process_task
    task_value = self.huey.execute(task)
  File "/usr/local/lib/python3.6/site-packages/huey/api.py", line 357, in execute
    result = task.execute()
  File "/usr/local/lib/python3.6/site-packages/huey/api.py", line 842, in execute
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/huey/contrib/djhuey/__init__.py", line 108, in inner
    return fn(*args, **kwargs)
  File "/code/app/tasks.py", line 89, in send_email
    email_message.send()
  File "/usr/local/lib/python3.6/site-packages/django/core/mail/message.py", line 348, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 111, in send_messages
    sent = self._send(message)
  File "/usr/local/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 127, in _send
    self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
  File "/usr/local/lib/python3.6/smtplib.py", line 888, in sendmail
    raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (432, b'4.3.2 STOREDRV.ClientSubmit; sender thread limit exceeded [Hostname=DM5PR19MB1050.namprd19.prod.outlook.com]')
ERROR   process_task    Unhandled exception in worker thread
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/huey/consumer.py", line 169, in process_task
    task_value = self.huey.execute(task)
  File "/usr/local/lib/python3.6/site-packages/huey/api.py", line 357, in execute
    result = task.execute()
  File "/usr/local/lib/python3.6/site-packages/huey/api.py", line 842, in execute
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/huey/contrib/djhuey/__init__.py", line 108, in inner
    return fn(*args, **kwargs)
  File "/code/app/tasks.py", line 89, in send_email
    email_message.send()
  File "/usr/local/lib/python3.6/site-packages/django/core/mail/message.py", line 348, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 111, in send_messages
    sent = self._send(message)
  File "/usr/local/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 127, in _send
    self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
  File "/usr/local/lib/python3.6/smtplib.py", line 888, in sendmail
    raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (554, b'5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:050B0000, 17.43559:0000000094000000000000000000000000000000, 20.52176:140F248214004010F1030000, 20.50032:140F248285174010F1030000, 0.35180:0A00B681, 255.23226:F1030000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A00F784, 16.55847:EC000000, 17.43559:0000000068010000000000000000000000000000, 20.52176:140F2482140000100A00F736, 20.50032:140F24828517001181170000, 0.35180:00000000, 255.23226:00000000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:140F2482, 4.21921:DC040000, 255.27962:FA000000, 255.1494:A4010000, 0.37692:05000780, 0.37948:00000600, 5.33852:00000000534D545000000000, 4.56248:DC040000, 7.40748:010000000000010B32303A44, 7.57132:00000000000000003A346638, 1.63016:32000000, 4.39640:DC040000, 8.45434:0000060075AF4541000000000000000032000000, 5.10786:0000000031352E32302E303534382E3032303A444D35505231394D42313035303A34663832663161652D373465382D343830632D623637302D34326236313339313335383200401005000780, 255.1750:0A00FC83, 255.31418:41010000, 0.22753:0A001E85, 255.21817:DC040000, 4.60547:DC040000, 0.21966:4B010000, 4.30158:DC040000 [Hostname=DM5PR19MB1050.namprd19.prod.outlook.com]')

这是我在settings.py上的配置我尝试将端口更改为587,尝试使用gmail帐户但不起作用

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp-mail.outlook.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 25
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
python django hotmail
1个回答
5
投票

它可能在settings.py或您的视图中缺少“Email From”变量。试试这个:

EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.live.com'
EMAIL_HOST_USER = '[email protected]'
DEFAULT_FROM_EMAIL = '[email protected]'
EMAIL_FROM = '[email protected]'
EMAIL_HOST_PASSWORD = 'yourpassword'
EMAIL_PORT = 587

DEFAULT_FROM_EMAIL用于库存Django视图,但如果你有自己的自定义视图,那么你也可以导入这些变量:

from django.conf import settings

send_mail(
    mail_subject,
    message,
    settings.EMAIL_FROM,
    [to_email],
    fail_silently=False,
)
© www.soinside.com 2019 - 2024. All rights reserved.