更新:在一位IT朋友的建议下,我在所有服务器上运行后缀,而不是制造一台云邮件服务器。到目前为止,这是我的解决方案:
/etc/postfix/main.cf
# output of hostname -f - mail from local users appears to come from here
myhostname = domU-01-02-03-04-05-06.compute-1.internal
# Local delivery - include all 127.0.0.1 aliases from /etc/hosts
mydestination = $myhostname, $mydomain, rest_of_entries_from_hosts
# Needed for address translation to work
myorigin = $mydomain
# Talking to MS Online
# :submission = port 587
relayhost = [smtp.mail.microsoftonline.com]:submission
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = # Yes, leave empty
smtp_tls_security_level = encrypt
smtp_generic_maps = hash:/etc/postfix/generic
# Enable if you need debugging, but it does leak credentials to the log
#debug_peer_level = 2
#debug_peer_list = smtp.mail.microsoftonline.com
# Only listen on the local interfaces (not the public)
inet_interfaces = localhost
# I left out a bunch of CentOS defaults. postconf -n is your friend.
# These are included
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
/etc/postfix/sasl_passwd
# Run postmap /etc/postfix/sasl_passwd after editing
# Also, chown root:root; chmod 600
smtp.mail.microsoftonline.com relayer@hosteddomain.com:YourP@ssw0rd
/etc/postfix/generic
# Run postmap /etc/postfix/generic
# I've seen local mail come from either source
# output of dnsdomainname
@compute-1.internal relayer@hosteddomain.com
# output of hostname -f
@domU-01-02-03-04-05-06.compute-1.internal relayer@hosteddomain.com
/etc/aliases
# Run newaliases after changing
# Lot of stuff here. Mostly, just make sure the graph points to root, such as
mailer-daemon: postmaster
postmaster: root
# And the important part - your email or distribution group
root: awsadmins@hosteddomain.com
/etc/passwd
# Sometimes it helps to expand the name, so email comes from 'root at aws host 5'
# rather than just 'root'
# Was
#root:x:0:0:root:/root:/bin/bash
# Is
root:x:0:0:root on aws host 5:/root:/bin/bash
我很高兴的事情:
- 许多邮件被发送到root用户,其中一行
alias
指示谁接收它。
- 来自本地用户的所有邮件都转换为来自的邮件
relayer@hosteddomain.com
,因此它通过MS Online SMTP服务器获取。
- postfix的文档比sendmail更好。
我不满意的事情:
- 每个主机都需要自定义更改,并且需要几个步骤。我写了一个bash脚本来提供帮助。
- 该
passwd
名招并不总是工作,它可能很难找出服务器邮件的来源。
- 发送的每封邮件都会在日志中显示三个警告:
warning: smtp.mail.microsoftonline.com[65.55.171.153] offered null AUTH mechanism list
(SMTP服务器AUTH
在之前STARTTLS
但AUTH LOGIN
之后发送空列表)。
certificate verification failed for smtp.mail.microsoftonline.com: num=20:unable to get local issuer certificate
(证书周围有一些配置选项,但是不确定证书更新时邮件传递是否中断)
certificate verification failed for smtp.mail.microsoftonline.com: num=27:certificate not trusted
(与#2相同)
感谢serverfault社区在邮件服务器上分享了强烈的意见。