0
我試圖安排異步電子郵件作業。 我使用django-rq作爲排隊機制。我已經嘗試了許多修補程序,例如更改密碼,確保它是正確的等我可以通過REPL手動發送SMTP。調度異步電子郵件作業失敗,並顯示SMTPAuthenticationError錯誤:(535,'5.7.3身份驗證失敗')
更新#1:設備正在由工作人員正確地拾取,只要我能確定。作業正確地爲settings.DEFAULT_FROM_EMAIL
選取正確的值,並將正確的電子郵件地址設置爲send_mail的arg。
下面的代碼成功地工作(無django的-RQ):
send_mail(
newClaim.linkedOffer.commsPromoHeadline,
msg_plain,
settings.DEFAULT_FROM_EMAIL,
[newRecipient.email],
html_message=msg_html,
)
而下面的代碼生成一個SMTP認證錯誤(回溯下向下):
django_rq.enqueue(
send_mail,
newClaim.linkedOffer.commsPromoHeadline,
msg_plain,
settings.DEFAULT_FROM_EMAIL,
[newRecipient.email],
html_message=msg_html,
)
回溯:
Traceback (most recent call last):
File "/home/user1/webapps/dev_django_platform/ENV/lib/python2.7/site-packages/rq/worker.py", line 568, in perform_job
rv = job.perform()
File "/home/user1/webapps/dev_django_platform/ENV/lib/python2.7/site-packages/rq/job.py", line 495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/home/user1/webapps/dev_django_platform/lib/python2.7/Django-1.7.7-py2.7.egg/django/core/mail/__init__.py", line 62, in send_mail
return mail.send()
File "/home/user1/webapps/dev_django_platform/lib/python2.7/Django-1.7.7-py2.7.egg/django/core/mail/message.py", line 286, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/user1/webapps/dev_django_platform/lib/python2.7/Django-1.7.7-py2.7.egg/django/core/mail/backends/smtp.py", line 92, in send_messages
new_conn_created = self.open()
File "/home/user1/webapps/dev_django_platform/lib/python2.7/Django-1.7.7-py2.7.egg/django/core/mail/backends/smtp.py", line 59, in open
self.connection.login(self.username, self.password)
File "/usr/local/lib/python2.7/smtplib.py", line 622, in login
raise SMTPAuthenticationError(code, resp)
SMTPAuthenticationError: (535, '5.7.3 Authentication unsuccessful')
爲什麼拋出一個異常,我該如何解決它?
謝謝,但這項工作似乎正在提取設置正確。例如,上面的參數之一是settings.DEFAULT_FROM_EMAIL,它在作業內被設置爲django設置文件中的值。我將使用此信息更新問題 – AndrewO
我們沒有將任何身份驗證信息傳遞給'send_email' - Django向他們提供了詳細信息,甚至可能設置了連接。排列任務時仍在讀取設置,該任務仍在django中。 – masnun
我明白你現在在說什麼。我在這裏登錄了一個問題https://github.com/ui/django-rq/issues/148 – AndrewO