阿里云ECS这是个大坑

从来不用国内的服务,但是没有办法,为了速度还是只能在国内找,矮子里挑个高的,只能选择阿里云。。。但是随之而来的是各种大坑。。

ECS 封掉了25端口,也就是说你不能在上面创建任何邮件服务器。。。阿里云工单的回答是,只能使用阿里云云邮箱或者第三方,需要修改代码。。。

修改你妹妹啊。。我是直接用bash 调用postfix做发件服务,没有代码。。。

找了一晚上加一上午,目前最好的办法就是使用qq 的免费企业邮箱。。但是qq 比较鬼的是。。他在文档中没有标明有587端口。。但是你确可以使用这个端口。。。465 是ssl 端口,这样配置起来会比较麻烦。。

首先是创建qq的免费企业邮箱,得到smtp 信息

smtp:  smtp.exmail.qq.com:587

TLS

然后在centos 里面安装postfix 和 sasl 模块

sudo yum install postfix cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain -y

编辑 /etc/postfix/main.cf, 然后加上

relayhost = [smtp.exmail.qq.com]:587

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_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sender_dependent_authentication = yes
smtp_generic_maps = hash:/etc/postfix/generic

在/etc/postfix/sasl_passwd 里面写用户名和密码, 比如说用户名为 [email protected], 密码为iamhippo, 那么就这么写:

[smtp.exmail.qq.com]:587 [email protected]:iamhippo

在/etc/postfix/generic 要重写mail from 的地址,假如你的hostname 是i.iamhippo.com, 那么就可以写成:

@i.iamhippo.com [email protected]

 

最后就是生成hash 数据库了:

postmap /etc/postfix/sasl_passwd
postmap /etc/postfix/generic
chmod 600 /etc/postfix/sasl_passwd*

然后我们只需要重启postfix,就大功告成

service postfix restart

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.