postfix搭建内网邮件转发服务器

Profix 搭建smtp邮件转发

有图好说话

在这里插入图片描述
mail client内部网络无法连接外网,通过mail relayserver发送邮件

本测试使用centos 7版本
mail relayserver:192.168.160.132

安装postfix
默认系统已经安装postfix,如果没装则可以按照一下方式安装
yum install -y postfix

服务管理
systemctl start postfix #启动

配置文件
/etc/postfix/main.cf
编辑配置文件
vim /etc/postfix/main.cf

inet_interfaces = all		#监听端口
inet_protocols = ipv4		#使用IPV4进行通讯
relayhost = [smtp.163.com]:25	#转发的服务器:端口
smtp_sasl_auth_enable = yes		#开启sasl验证
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd		#指定密码文件
smtp_tls_security_level = encrypt		#postfix SMTP客户端的默认SMTP TLS安全级别
smtp_sasl_security_options = noanonymous	#禁止匿名用户

配置验证密码文件
vim /etc/postfix/sasl_passwd

[smtp.163.com]:25    test@163.com:xxn15249274366
postmap hash:/etc/postfix/sasl_passwd

使用postmap在/etc/postfix/目录下生成.db密码文件

systemctl restart postfix		#重启postfix服务

SMTP服务本机测试:

[root@s postfix]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 bogon ESMTP Postfix
mail from:test@163.com
250 2.1.0 Ok
rcpt to: 123456@qq.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
this is test mail postfix
.
250 2.0.0 Ok: queued as D433586D2

成功

注意要点:
  1. main.cnf配置文件里的smtp服务器地址要和sasl_passwd文件中保持一致。
  2. sasl_passwd文件中密码是邮箱的授权码,不要写成邮箱密码。
  3. 每次修改了sasl_passwd文件必须要使用postmap命令重新生成一次新的.db文件。
  4. 一定要在防火墙开放smtp的端口;默认是 25 端口。
  5. 在需要发邮件的服务配置里,发件人邮箱和密码一定要和sasl_passwd文件中指定的保持一致。
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值