不知道为什么要这么做,姑且做个备忘。
可选步骤:使用外部SMTP服务器
建立文件 /etc/postfix/sasl_passwd ,内容为
1 |
[smtp.server.domain]:port username:password |
建立对应的Hash DB
1 |
postmap /etc/postfix/sasl_passwd |
控制访问权限(里面有明文密码)
1 2 |
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db |
打开配置文件 /etc/postfix/main.cf ,新建/更改行
1 2 3 4 5 6 7 8 9 10 11 12 |
# SMTP server relayhost = [smtp.server.domain]:port # enable SASL authentication smtp_sasl_auth_enable = yes # disallow methods that allow anonymous authentication. smtp_sasl_security_options = noanonymous # where to find sasl_passwd smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd # Enable STARTTLS encryption smtp_use_tls = yes # where to find CA certificates smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt |
配置本地邮件转发
设立转发配置文件 /etc/postfix/virtual ,内容:
1 2 3 4 |
# Single receiver, more than 1 forwarding destination me@example.org destination@gmail.com dest2@gmail.com # Wildcard username @example.org destination@gmail.com |
同样建立Hash DB:
1 |
postmap /etc/postfix/virtual |
修改配置文件:
1 2 3 4 5 6 7 8 |
# forwarding server virtual_alias_domains = localhost_hostname virtual_alias_maps = hash:/etc/postfix/virtual # Enable TLS smtp_use_tls=yes smtp_tls_security_level = encrypt smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt |
重启一下服务
1 |
systemctl restart postfix.service |