postfix - out bound control

最後更新: 2016-11-11

 

介紹

設定不能發信去某些 Domain

 


檔案: main.cf

proxy_read_maps = ........
 $smtpd_recipient_restrictions

smtpd_recipient_restrictions = ..........
 check_recipient_access proxy:mysql:/etc/postfix/mysql/check_recipient_access.cf
 permit_mynetworks, permit_sasl_authenticated,
 reject_unauth_destination
 ..........

檔案: check_recipient_access.cf

user        = vmail
password    = ?????????????
hosts       = 127.0.0.1
port        = 3306
dbname      = vmail
query       = SELECT action FROM `outgoing_recipient_control` WHERE '%s' REGEXP account AND enable="1" ORDER BY priority DESC LIMIT 1;

檔案: outgoing_recipient_control.sql

CREATE TABLE IF NOT EXISTS `outgoing_recipient_control` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `account` varchar(255) NOT NULL,
  `action` enum('DUNNO','REJECT','DISCARD') NOT NULL DEFAULT 'DUNNO',
  `enable` enum('0','1') NOT NULL DEFAULT '1',
  `priority` int(1) NOT NULL DEFAULT '5',
  `modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `remark` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`),
  UNIQUE KEY `id_2` (`id`),
  KEY `id_3` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

Log:

Apr 30 16:43:54 mail postfix/smtpd[5149]: NOQUEUE: reject: RCPT from mail.local[127.0.0.1]: 554 5.7.1 <[email protected]>: 
Recipient address rejected: Access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<192.168.123.103>

 

 

Creative Commons license icon Creative Commons license icon