后缀 – 限制域内的通信

我正在build立一个后缀云服务器,我想限制域内的通信。 也就是说,用户只能与在电子邮件域中拥有地址的其他用户进行通信 – 不会向其他域(如Gmail,Hotmail等)传入或传出消息:

YES: [email protected] <----> [email protected] NO: [email protected] <----> [email protected] 

什么是简单的方法来做到这一点? 我正在使用postfix / courier。 谢谢。


更新 – 如何做到这一点:

/etc/postfix/main.cf

 # first rule makes sure users cannot sent to people outside the domain # (check_recipient_access is the one you want) smtpd_recipient_restrictions = check_recipient_access regexp:/etc/postfix/recipient-access, permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, permit # block sends from external users # (who cannot be authenticated by the system) smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_authenticated_sender_login_mismatch, reject # use mysql to find authenticated addresses smtpd_sender_login_maps = mysql:/etc/postfix/mysql-sender-login-maps.cf # (could also use pcre or some other method) #smtpd_sender_login_maps = pcre:/etc/postfix/sender-login-maps.pcre 

/etc/postfix/mysql-sender-login-maps.cf

 user = dbuser password = dbpassword hosts = 127.0.0.1 dbname = dbname # this will depend on your db/table structure query = SELECT email FROM users WHERE email='%s' and enabled=1; 

testing:

 $ postmap -q [email protected] mysql:/etc/postfix/mysql-sender-login-maps.cf 

如果[email protected]存在于用户表中,则应该返回;如果不存在,则返回任何内容。

如果你决定在Ubuntu中使用pcre( apt-get install postfix-pcre ),那么在/etc/postfix/sender-login-maps.pcre

 /^(.*@domain.com)$/ ${1} 

testing:

 $ postmap -q [email protected] pcre:/etc/postfix/sender-login-maps.pcre 

如果域名匹配,则返回[email protected]如果不匹配,则返回任何内容。


最后在/etc/postfix/recipient-access

 !/@domain.com/ REJECT 

谢谢@NickW!

限制外部人员向服务器发送信息的最简单的方法是仅允许经过SASLauthentication的人员发送,然后将smtpd_sender_restrictions定义为reject_sender_login_mismatch, reject只允许SASLauthentication的用户,并且仅当其FROM地址与其login名相匹配时。 创build一个select用户电子邮件作为授权地址的SQL查询非常简单。

你会设置smtpd_recipient_restrictionscheck_recipient_access regexp:/etc/postfix/recipient-access ,在recipient_access里面有类似于!/@domain.com/ REJECT这意味着任何TO / CC / BCC地址不是'你的域名被拒绝。

这不是一个完整的书面,但它应该让你在正确的轨道上。