ExtMail服务器社区's Archiver

kently 发表于 2007-2-28 10:38

限制部分用戶發送和接收外部郵件(已成功,大家分享)

  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

raykingecs 发表于 2007-2-28 10:41

顶一下LZ。

fandy 发表于 2007-2-28 10:47

多谢!

kently 发表于 2007-2-28 10:51

昨天想了一天,頭都大了,資料也找了N多,都不對,今天終於搞定

kently 发表于 2007-2-28 10:57

如果是多網段用戶,或者多個郵件服務器,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

fandy 发表于 2007-2-28 11:23

申请加精!

ethan 发表于 2007-2-28 17:48

对,应该加精!

WJW 发表于 2007-7-26 10:55

我按楼主设定的,怎么还是限制不了。能详细说说吗,哪个文件是控制发送的和接收的邮件名。

hzqbbc 发表于 2007-7-27 11:42

楼上无法作成功的话,请多对比作者的文档,作者的文档没有什么错误的,是经过大量测试,不少朋友都成功了。看docs一定要仔细,另外,先按照作者的sample写配置,等弄明白了,再自己改,这样问题会少一些。

vincentzpf 发表于 2007-8-12 15:55

不错!测试通过!:lol :lol :lol :lol

mecyl 发表于 2007-9-10 10:27

请问在local_domains,local_senders这些列表文件中,可以使用通配符吗?格式应该怎么用?

yama998 发表于 2007-12-8 17:50

[font=SimSun]我也有测试过,但只成功了一半,即:

[/font][font=SimSun]可以控制某个用户不能接收外网邮件,[/font]
[font=SimSun]但不能控制这个用户往外网发送邮件。

[/font][font=SimSun]请各位帮忙指点[/font]:)

[[i] 本帖最后由 yama998 于 2007-12-8 17:53 编辑 [/i]]

xdb1010 发表于 2008-3-18 09:16

我的测试不成功,就好象这个restrictions根本不起任何作用

xdb1010 发表于 2008-3-19 14:09

smtpd_restriction_classes对客户端有用,对webmail却无效

[url]http://www.extmail.org/forum/viewthread.php?tid=6118[/url]

我的也是这样,内部域用户限制对webmail无效

xdb1010 发表于 2008-3-19 14:58

smtpd_restriction_classes对客户端有用,对webmail却无效

[url]http://www.extmail.org/forum/viewthread.php?tid=6118[/url]

我的也是这样,内部域用户限制对webmail无效

jick 发表于 2008-6-26 17:17

[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]

raykingecs 发表于 2008-6-26 17:23

用最新版本,webmail发送已经改过了,不再直接调用sendmail 。

rouwangwm 发表于 2008-7-17 10:58

回复 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)

不知道怎么解决??各位大哥帮帮忙!

sem001 发表于 2008-7-18 12:43

我按照上面的做。怎么只能限制 外部邮件发不进来。 但是 限制不了 往外发。请教下。是很么问题啊。

ruochen0926 发表于 2008-7-21 15:25

mark一下
我也准备做这个需求

fendsion 发表于 2008-8-20 15:55

用outlook测试成功,但对web来说,还是不能成功!

我按 kently的方法来做,用outlook测试成功,但对web来说,还是不能成功!请问老大指点一下!感谢老大!!:handshake

twtitxyga 发表于 2008-9-1 21:29

这个是用什么认证的呢?

twtitxyga 发表于 2008-9-1 21:40

[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]
这几句是做什么的?在那里设?

lingping 发表于 2008-9-8 17:30

我也做了一遍,但未被生效。

事实上,这一段配置大部分的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发邮件

twtitxyga 发表于 2008-9-9 22:56

哈哈哈!经过我几天的研究!终于成功了!
但是有一个问题就是:
怎么样自动更?local_recipients
???这些数据库呢?

leftleg 发表于 2008-9-16 16:04

#########################

[[i] 本帖最后由 leftleg 于 2008-9-16 16:32 编辑 [/i]]

leftleg 发表于 2008-9-16 16:31

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥

pxczy 发表于 2008-11-29 09:20

成功了?还是没有成功?

页: [1] 2

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.