限制部分用戶發送和接收外部郵件(已成功,大家分享)
1) 編輯main.cf,在最後添加smtpd_restriction_classes = local_only, local_only1
local_only = check_recipient_access hash:/etc/postfix/local_domains,reject
local_only1 = check_sender_access hash:/etc/postfix/local_domains,reject
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/local_senders,
check_recipient_access hash:/etc/postfix/local_recipients,
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_rhsbl_sender,
reject_unknown_sender_domain,
reject_invalid_hostname
注:從第5行開始前面空一格.
2) 新增local-domains , local_senders , local_recipients
local_domains:
domain.com OK
192.168.0.1 OK
local_senders:
[email]kently@domain.com[/email] local_only
local_recipients:
[email]kently@domain.com[/email] local_only1
3) postmap hash:/etc/postfix/local_domains
postmap hash:/etc/postfix/local_senders
postmap hash:/etc/postfix/local_recipients
4) postfix reload 顶一下LZ。 多谢! 昨天想了一天,頭都大了,資料也找了N多,都不對,今天終於搞定 如果是多網段用戶,或者多個郵件服務器,local_domains裡面直接添加即可.
sample:
domain.com OK
192.168.0.1 OK
domain1.com OK
192.168.1.1 OK
domain2.com.cn OK
192.168.2.1 OK 申请加精! 对,应该加精! 我按楼主设定的,怎么还是限制不了。能详细说说吗,哪个文件是控制发送的和接收的邮件名。 楼上无法作成功的话,请多对比作者的文档,作者的文档没有什么错误的,是经过大量测试,不少朋友都成功了。看docs一定要仔细,另外,先按照作者的sample写配置,等弄明白了,再自己改,这样问题会少一些。 不错!测试通过!:lol :lol :lol :lol 请问在local_domains,local_senders这些列表文件中,可以使用通配符吗?格式应该怎么用? [font=SimSun]我也有测试过,但只成功了一半,即:
[/font][font=SimSun]可以控制某个用户不能接收外网邮件,[/font]
[font=SimSun]但不能控制这个用户往外网发送邮件。
[/font][font=SimSun]请各位帮忙指点[/font]:)
[[i] 本帖最后由 yama998 于 2007-12-8 17:53 编辑 [/i]] 我的测试不成功,就好象这个restrictions根本不起任何作用 smtpd_restriction_classes对客户端有用,对webmail却无效
[url]http://www.extmail.org/forum/viewthread.php?tid=6118[/url]
我的也是这样,内部域用户限制对webmail无效 smtpd_restriction_classes对客户端有用,对webmail却无效
[url]http://www.extmail.org/forum/viewthread.php?tid=6118[/url]
我的也是这样,内部域用户限制对webmail无效 [quote]原帖由 [i]xdb1010[/i] 于 2008-3-19 14:09 发表 [url=http://www.extmail.org/forum/redirect.php?goto=findpost&pid=40039&ptid=4102][img]http://www.extmail.org/forum/images/common/back.gif[/img][/url]
smtpd_restriction_classes对客户端有用,对webmail却无效
[url]http://www.extmail.org/forum/viewthread.php?tid=6118[/url]
我的也是这样,内部域用户限制对webmail无效 [/quote]
老大们 有没有什么办法让webmian 也有效啊~!
这个是我在网上找到的 老大帮看看!
1)定义类send2hrall:
smtpd_restriction_classes = send2hrall
send2hrall =
check_sender_access mysql:/usr/local/etc/postfix/mysql-send2hrall.cf,reject
配置文件 send2hrall.cf内容如下:
hosts = localhost
user = mailuser
password = mailpasswd
dbname = maildatabase
query = select access from mysql-send2hrall where source = '%s'
2)对发给[email]hrall@mydomain.com.cn[/email]的发件人进行审核:
smtpd_sender_restrictions =中添加:
check_recipient_access hash:/usr/local/etc/postfix/hrallclass
在/usr/local/etc/postfix目录下建立该文件
# ee /usr/local/etc/postfix/hrallclass
# postmap /usr/local/etc/postfix/hrallclass(会生成hrallclass.db)
文件/usr/local/etc/postfix/hrallclass内容如下:
[email]hrall@mydomain.com.cn[/email] send2hrall
3)设定数据表mysql-send2hrall记录哪些人可以给[email]hrall@mydomain.com.cn[/email]发送邮件
数据库中建立表mysql-send2hrall中使用的表,
表结构如下:
CREATE TABLE `mysql_send2hrall` (
`id` int(11) unsigned NOT NULL auto_increment,
`ctime` int(11) unsigned default NULL,
`source` varchar(128) NOT NULL default '',
`access` varchar(16) NOT NULL default '',
`type` char(1) NOT NULL default 'S',
PRIMARY KEY (`id`),
KEY `source` (`source`,`type`,`access`,`ctime`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=gb2312;
对应数据格式如下
source access
[email]oksender@mydomain.com.cn[/email] OK
[email]oksender@otherdomain.com[/email] OK
过程大概如下:
在smtp发送邮件的时候,通过 check_recipient_access 中获知:[email]hrall@mydomain.com.cn[/email]该邮件接收的时候需要根据类send2hrall核查,而该类中定义了发件人核查的需求,从数据库表中获取此需求的具体结果。譬如上例中,如果发件人是[email]oksender@mydomain.com.cn[/email],获取的结果就为ok,这样smtp将此人发给[email]hrall@mydomain.com.cn[/email]的邮件进行正常投递;其他如果不在数据库表mysql-send2hrall中的人,将根据下面reject的定义进行回绝。
本篇文章来源于 优优邮箱网[url]www.uuxi.cn[/url]原文链接:[url]http://www.uuxi.cn/html/news/mail-ser/Postfix/20070812/206.html[/url] 用最新版本,webmail发送已经改过了,不再直接调用sendmail 。
回复 1# kently 的帖子
When I run:postmap hash:/etc/postfix/local_senders
I get:
postmap: /usr/lib/mysql/libmysqlclient.so.14: no version information available (required by postmap)
不知道怎么解决??各位大哥帮帮忙! 我按照上面的做。怎么只能限制 外部邮件发不进来。 但是 限制不了 往外发。请教下。是很么问题啊。 mark一下
我也准备做这个需求
用outlook测试成功,但对web来说,还是不能成功!
我按 kently的方法来做,用outlook测试成功,但对web来说,还是不能成功!请问老大指点一下!感谢老大!!:handshake 这个是用什么认证的呢? [quote]原帖由 [i]kently[/i] 于 2007-2-28 10:38 发表 [url=http://www.extmail.org/forum/redirect.php?goto=findpost&pid=28503&ptid=4102][img]http://www.extmail.org/forum/images/common/back.gif[/img][/url]1) 編輯main.cf,在最後添加
smtpd_restriction_classes = local_only, local_only1
local_only = check_recipient_access hash:/etc/postfix/local_domains,reject
local_only1 = check_sender_access hash:/etc/ ... [/quote]
这几句是做什么的?在那里设? 我也做了一遍,但未被生效。
事实上,这一段配置大部分的postfix都是推荐配置的:[code]smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_rhsbl_sender,
reject_unknown_sender_domain,
reject_invalid_hostname[/code]只有这几行才是为此功能而添加的[code] smtpd_restriction_classes = local_onlya, local_onlyb
local_onlya = check_recipient_access hash:/etc/postfix/local_domains,reject
local_onlyb = check_sender_access hash:/etc/postfix/local_domains,reject
check_sender_access hash:/etc/postfix/local_senders,
check_recipient_access hash:/etc/postfix/local_recipients, [/code]domain.com ok
192.168.1.1 ok 此IP应该就是邮件服务器的IP吧
该做的都做了,但还是能往163发邮件 哈哈哈!经过我几天的研究!终于成功了!
但是有一个问题就是:
怎么样自动更?local_recipients
???这些数据库呢? #########################
[[i] 本帖最后由 leftleg 于 2008-9-16 16:32 编辑 [/i]] ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥ 成功了?还是没有成功?
页:
[1]
2