我被要求做一些系统管理员并将遗留的PHP Web应用程序移动到运行Debian的Amazon EC2实例。我已经这样做了,并且成功地从postfix发送了电子邮件。
以前的系统管理员表示担心服务器没有使用电子邮件中继,并且使用SES的请求似乎很简单。我已经从Rackspace实例使用Mailgun实现了一个邮件中继,虽然不是很简单,但我在几个小时内完成了这项工作。
我没有发现SES过程非常简单,我怀疑这是因为我不熟悉使用证书。
最初我使用此处的说明设置服务 http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
[email-smtp.us-west-2.amazonaws.com]:25 USERNAME:PASSWORD
postmap hash:/ etc / postfix / sasl_passwd
创建sasl_passwd.db
/etc/postfix/master.cf中没有smtp_fallback_relay
我通过安装apt-get install sasl2-bin和
创建了证书openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
并在我的main.cf中指向postfix(在本文末尾)。
我使用sendmail通过Python发送电子邮件
SessionFactory
但发送时我一直有错误时间:
SENDMAIL = "/usr/sbin/sendmail" # sendmail location
FROM = "andy@travelinsurancequotes.com.au"
#TO = ["kirstie@travelinsurancequotes.com.au", "jason@slatescience.com"]
TO = ["jason@slatescience.com"]
SUBJECT = "Artog SMTP server is working!"
TEXT = "Sending emails on the TIQ webserver is working"
# Prepare actual message
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send the mail
import os
p = os.popen("%s -f %s -t -i" % (SENDMAIL, FROM), "w")
p.write(message)
status = p.close()
if status:
print "Sendmail exit status", stat
我可以通过端口25连接
Feb 26 03:18:19 lamp postfix/error[23414]: 5DE3240508: to=<jason@slatescience.com>, relay=none, delay=0.02, delays=0.02/0/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to email-smtp.us-west-2.amazonaws.com[54.187.123.10]:25: Connection timed out
我的main.cf文件是
root@lamp /home/www# telnet email-smtp.us-west-2.amazonaws.com 25
Trying 54.149.142.243...
Connected to ses-smtp-us-west-2-prod-14896026.us-west-2.elb.amazonaws.com.
Escape character is '^]'.
220 email-smtp.amazonaws.com ESMTP
答案 0 :(得分:2)
AWS EC2对发送的邮件有某种限制..
我遇到了这个错误,亚马逊支持部门告诉我填写此表单以取消限制。
https://aws.amazon.com/forms/ec2-email-limit-rdns-request
我希望这会有所帮助