返回列表 发帖

配置postfix使用远程smtp服务器relay邮件

一、服务器端允许指定客户端的relay
  1. #vi /etc/postfix/main.cf
  2. relay_domains = $mydestination
  3. mynetworks = 127.0.0.0/8, 1.2.3.4, 1.2.3.5
复制代码

说明:这里我们选择在mynetworks里面添加IP,而不是在relay_domains里添加域名,我们有很多站,而且都是在固定的几台服务器上的,所以使用这种方式更加便捷。

二、客户端配置
2.1 安装PLAIN,LOGIN验证机制接口软件包,用于向远程smtp服务器提供密码
  1. # yum -y install cyrus-sasl-plain
复制代码

2.2 配置postfix主文件
  1. #vi /etc/postfix/main.cf
  2. #进行tls加密连接
  3. smtp_use_tls = yes
  4. #启用sasl验证
  5. smtp_sasl_auth_enable = yes
  6. #中继服务器地址,不指定端口就是默认的tcp/25端口
  7. relayhost = [mail.libertyvps.com]:587
  8. #指定sasl验证文件路径
  9. smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
  10. #指定发件人,可以不设置
  11. #smtp_generic_maps=hash:/etc/postfix/generic
  12. #sasl验证的安全选项,这里设置为不允许明文验证和匿名用户登陆
  13. smtp_sasl_security_options = noplaintext, noanonymous
复制代码

2.3 sasl验证文件内容
  1. # cat /etc/postfix/sasl_passwd
  2. [mail.libertyvps.com]:587    username:password
复制代码

2.4 如果需要指定本地用户作为特定的远程用户来发送邮件
  1. # tail -n1 /etc/postfix/generic
  2. root@localhost    username@libertyvps.com
复制代码

2.5 生成哈希表
  1. # postmap /etc/postfix/generic
  2. # postmap /etc/postfix/sasl_passwd
复制代码

2.6 启动服务
  1. # /etc/init.d/saslauthd start
  2. # service postfix restart
复制代码

=================美丽的分割线===============
补充:Gmail的可用smtp服务器地址
gmail-smtp.l.google.com
smtp.gmail.com

下面是debian下面设置EXIM4的文章链接,debian的dpkg-reconfigure命令还是蛮方便的
http://www.iteye.com/topic/327920
http://www.yangel.cn/system/linux/debian-exim4-smarthost/

TOP

有空拜读一下,谢谢分享

TOP

返回列表