![](/img/trans.png)
[英]sending email django with postfix (without an explicit postfix server)
[英]Django; sending email from my own postfix mail server
在托管django網站的vps上,我設置了一個后綴郵件服務器,供django用於發送電子郵件。 郵件服務器正常工作。 在vps命令行上使用mutt,我可以向其他帳戶(例如gmail等)收發郵件。
但是,我仍然無法使用postfix從django發送郵件。
我遵循https://stackoverflow.com/a/28143166/1009979中的建議進行設置...
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
當我嘗試
>>> from django.core.mail import send_mail
>>> send_mail('Subject here', 'Here is the message.', 'from@example.com', ['andrews.markw@gmail.com'])
我懂了
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail
return mail.send()
File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 107, in send_messages
sent = self._send(message)
File "/home/andrews/development/wilhelm-development/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 123, in _send
self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n'))
File "/usr/lib/python2.7/smtplib.py", line 733, in sendmail
raise SMTPRecipientsRefused(senderrs)
SMTPRecipientsRefused: {u'andrews.markw@gmail.com': (550, '5.7.1 <vps7718.webhosting.uk.com>: Helo command rejected: Host not found')}
當我用google搜索有關SMTPRecipientsRefused:
建議或Helo command rejected: Host not found
,沒有明顯的解決方案出現。
設置有問題嗎?
我應該提一下,django電子郵件沒有任何一般性問題。 例如,我可以從Django發送gmail電子郵件(遵循此處描述的設置和過程https://stackoverflow.com/a/23402208/1009979 )。
請確保您有permit_mynetworks
在smtpd_helo_restrictions
和smtpd_recipient_restrictions
在/etc/postfix/main.cf
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.