我真的需要你的帮助。大约一个星期,我试图在我的服务器上配置邮件。我使用nginx->;uwsgi->;django应用程序。 问题是邮件服务器只能与以下后端一起工作:
class SSLEmailBackend(EmailBackend):
def open(self):
if self.connection:
return False
try:
self.connection = smtplib.SMTP_SSL(
self.host, self.port, local_hostname=DNS_NAME.get_fqdn())
if self.username and self.password:
self.connection.ehlo()
# Remove CRAM-MD5 authentication method
self.connection.esmtp_features['auth'] = 'PLAIN LOGIN'
self.connection.login(self.username, self.password)
return True
except:
if not self.fail_silently:
raise
我的设置:
^{pr2}$在当地,它工作得很好!在
最奇怪的是,可以在服务器控制台中发送消息而不会出现任何错误:
>> from django.core.mail import send_mail
>> send_mail('test email', 'hello world', '', ['my_test@gmail.com'])
当我试图注册一个新用户时,问题就来了。我使用Django userena后端进行注册。注册成功,但电子邮件只在服务器上发送到/var/mail/user1
电子邮件文本:
rom MAILER-DAEMON Sun Oct 26 02:06:01 2014
Return-path: <>
Envelope-to: webmaster@localhost
Delivery-date: Sun, 26 Oct 2014 02:06:01 +0400
Received: from Debian-exim by mail.my_mail_server.com with local (Exim 4.80)
id 1Xi9TF-0002Wp-Ml
for webmaster@localhost; Sun, 26 Oct 2014 02:06:01 +0400
X-Failed-Recipients: test@test.com
Auto-Submitted: auto-replied
From: Mail Delivery System <Mailer-Daemon@elib.rshu.ru>
To: webmaster@localhost
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1Xi9TF-0002Wp-Ml@mail.my_mail_server.com>
Date: Sun, 26 Oct 2014 02:06:01 +0400
Status: O
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
test@test.com
Mailing to remote domains not supported
------ This is a copy of the message, including all the headers. ------
Return-path: <webmaster@localhost>
Received: from localhost ([::1] helo=mail.my_mail_server.com)
by mail.my_mail_server.com with esmtp (Exim 4.80)
(envelope-from <webmaster@localhost>)
id 1Xi9TF-0002Wm-Lv
for test@test.com; Sun, 26 Oct 2014 02:06:01 +0400
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Subject: =?utf-8?b?0KDQtdCz0LjRgdGC0YDQsNGG0LjRjyDQsiDRjdC70LXQutGC0YDQvtC90L0=?=
=?utf-8?b?0L7QuSDQsdC40LHQu9C40L7RgtC10LrQtSDQoNCT0JPQnNCj?=
From: webmaster@localhost
To: test@test.com
Date: Sat, 25 Oct 2014 22:06:01 -0000
....
我一直在检查userena,nginx等等,我不知道是什么问题。为什么它在本地和服务器控制台上都可以发送消息。请帮忙。在
您的邮件服务器未设置为接受远程邮件转发。来自服务器的错误消息是“不支持向远程域发送邮件”。因此,无论您连接到哪个邮件服务器都无法识别您的web服务器是一个“受信任的用户”,该用户的邮件应该被接受和转发。我会尽量让你的邮件服务提供商把你发送电子邮件的服务器列为白名单。在
相关问题 更多 >
编程相关推荐