【发布时间】:2015-10-28 10:27:59
【问题描述】:
在我托管 django 网站的 vps 上,我设置了一个 postfix 邮件服务器,供 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)。
【问题讨论】: