我被要求做一些系統管理員並將傳統PHP Web應用程序移動到運行Debian的Amazon EC2實例。我已經完成了這項工作,並且郵件已經成功從postfix發送。亞馬遜SES從Debian上的後綴修改EC2實例無法發送電子郵件
之前的系統管理員擔心服務器未使用電子郵件中繼,並且使用SES的請求看起來很簡單。我使用Rackspace實例中的Mailgun實現了郵件中繼,雖然不是微不足道的,但我在幾個小時內完成了這個任務。
我還沒有找到SES過程非常簡單,我懷疑這是因爲我不熟悉使用證書。
起初,我成立了服務這裏使用說明 http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
- 彈性IP設置爲服務器的SMTP服務器
- 創建IAM用戶創建
- 證書,並獲得了SMTP用戶名和密碼在 電子郵件smtp.us-west-2.amazonaws.com
- 我創建了一個/ etc/postfix/sasl_passwd文件與
[email-smtp.us-west-2.amazonaws.com]:25用戶名:密碼
- 然後我跑
postmap哈希:/等/後綴/ sasl_passwd
創建sasl_passwd.db
/etc/postfix/master.cf沒有smtp_fallback_relay在它
我通過安裝創建的證書的apt-get安裝SASL2-bin和
OpenSSL的REQ -x509 - 節點-days 365 -newkey RSA:2048 -keyout server.key -out server.crt這
,指着後綴這個在我的馬in.cf(在這篇文章的末尾)。
我使用sendmail通過Python
SENDMAIL = "/usr/sbin/sendmail" # sendmail location
FROM = "[email protected]"
#TO = ["[email protected]", "[email protected]"]
TO = ["[email protected]"]
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
發送一封電子郵件,但我不斷收到超時錯誤的發送:
Feb 26 03:18:19 lamp postfix/error[23414]: 5DE3240508: to=<[email protected]>, 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
我可以通過端口連接25
[email protected] /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
我的主。CF文件是
myhostname = travelinsurancequotes.com.au
mydomain = travelinsurancequotes.com.au
inet_interfaces = all
mynetworks_style = host
local_destination_recipient_limit = 300
local_destination_concurrency_limit = 5
recipient_delimiter=+
smtpd_banner = $myhostname
smtpd_sasl_auth_enable = yes
smtp_sasl_mechanism_filter = plain
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
smtpd_helo_required = yes
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/sslcerts/server.key
smtpd_tls_cert_file = /etc/postfix/sslcerts/server.crt
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
relayhost = [email-smtp.us-west-2.amazonaws.com]:25
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
感謝。不幸的是,我無法嘗試您的解決方案,因爲我不再有權限訪問。儘管如此,亞馬遜支持應該告訴我這一點。這種限制對許多人來說都是一個問題,這對於Rackspace來說並不是問題(儘管他們有其他問題,他們的支持很好)。與亞馬遜合作的決定是教條。 – MagicLAMP
其實我同意。我花了一些時間試圖弄清楚。驚訝於任何託管公司都會扼殺虛擬機的端口25.我仍在努力獲得rDNS設置,現在它報告爲我的EC2內部IP。 –