海运的博客

Postfix禁止转发伪造发件人邮件

发布时间:July 10, 2012 // 分类:Mail // No Comments

Postfix内网用户在转发邮件时可以任意填写发件人邮箱,给管理带来诸多不便,可以使用账号登录匹配发件人邮箱进行限制。
编辑Postfix配置文件:

#https://www.haiyun.me
cat /etc/postfix/main.cf
smtpd_sender_login_maps = hash:/etc/postfix/sasl_sender #用户与邮件账号匹配表
smtpd_sender_restrictions = 
      reject_sender_login_mismatch #拒绝发送邮件与登录用户不匹配的邮件
smtpd_recipient_restrictions =
#     permit_mynetworks,  #去除网络区域认证
      permit_sasl_authenticated #用户认证模式

新建用户与账号匹配表:

cat /etc/postfix/sasl_sender
root@www.haiyun.me       root

生成hash数据库:

postmap /etc/postfix/sasl_sender

伪造发件人发送邮件测试:

sendEmail -v -f test@www.haiyun.me -t mail@www.haiyun.me -s smtp.www.haiyun.me -u "test" -m "测试sendemail" -xu root -xp passwd
Feb 29 11:08:00 centos5 sendEmail[21973]: DEBUG => Connecting to smtp.www.haiyun.me:25
Feb 29 11:08:01 centos5 sendEmail[21973]: DEBUG => My IP address is: 192.168.1.3
Feb 29 11:08:01 centos5 sendEmail[21973]: SUCCESS => Received:     220 mail.www.haiyun.me ESMTP "ONOVPS Mail Server"
Feb 29 11:08:01 centos5 sendEmail[21973]: INFO => Sending:     EHLO centos5.7-x86
Feb 29 11:08:01 centos5 sendEmail[21973]: DEBUG => SMTP-AUTH: Using LOGIN authentication method
Feb 29 11:08:01 centos5 sendEmail[21973]: INFO => Sending:     AUTH LOGIN
Feb 29 11:08:01 centos5 sendEmail[21973]: SUCCESS => Received:     235 2.0.0 Authentication successful
Feb 29 11:08:01 centos5 sendEmail[21973]: DEBUG => User authentication was successful (Method: LOGIN)
Feb 29 11:08:01 centos5 sendEmail[21973]: INFO => Sending:     MAIL FROM:<test@www.haiyun.me>
Feb 29 11:08:01 centos5 sendEmail[21973]: SUCCESS => Received:     250 2.1.0 Ok
Feb 29 11:08:01 centos5 sendEmail[21973]: INFO => Sending:     RCPT TO:<mail@www.haiyun.me>
Feb 29 11:08:01 centos5 sendEmail[21973]: WARNING => The recipient <mail@www.haiyun.me> was rejected by the mail server, error follows:
Feb 29 11:08:01 centos5 sendEmail[21973]: WARNING => Received:     553 5.7.1 <test@www.haiyun.me>: Sender address rejected: not owned by user root
Feb 29 11:08:01 centos5 sendEmail[21973]: ERROR => Exiting. No recipients were accepted for delivery by the mail server.
分类
最新文章
最近回复
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...