postfix 自身的 bcc(密送)功能可以实现邮件备份和监控功能
- sender_bcc_maps 通过 postfix 发送出去的邮件
- recipient_bcc_maps 通过 postfix 接收到的邮件
- always_bcc 通过 postfix 发送和接收的任何邮件。参数是单独的 一个 邮件地址
需要注意的是,如果设置了整个域的 bcc,又为域内的某个用户单独设置了 bcc,则只有域的 bcc 会生效。bcc 不支持多个地址,只能是单个地址。 指定sender_bcc_maps和recipient_bcc_maps
[root@umail log]# postconf -e sender_bcc_maps=mysql:/etc/postfix/send_bcc_maps.cf
[root@umail log]# postcof -e recipient_bcc_maps=mysql:/etc/postfix/recipient_bcc_maps.cf
[root@umail log]# vi /etc/postfix/send_bcc_maps.cf
user = root
password = PassWord
hosts = localhost
dbname = xmail
table = monitor
select_field = monitor_to
where_field = username
additional_conditions = AND sender = '1'
[root@umail log]# vi /etc/postfix/recipient_bcc_maps.cf
user = root
password = PassWord
hosts = localhost
dbname = xmail
table = monitor
select_field = monitor_to
where_field = username
additional_conditions = AND recipient = '1'
# 读取monitor_to字段,当设置了发送监控值为1(启用)的情况
建立一个mysql表monitor来存储监控
DROP TABLE IF EXISTS `monitor`;
CREATE TABLE `monitor` (
`domain` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`monitor_to` varchar(128) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`sender` int(1) NOT NULL DEFAULT '0',
`recipient` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`username`),
KEY `domain` (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Monitor';
在表里面设置好接收地址,postfix reload 测试吧!