BCC

------

Postfix configs: main.cf:virtual_bcc_recipients_maps = proxy:mysql:/etc/postfix/mysql/mysql_virtual_bcc_recipients_maps.cf virtual_bcc_senders_maps = proxy:mysql:/etc/postfix/mysql/mysql_virtual_bcc_senders_maps.cf

# vi /etc/postfix/sql/mysql_virtual_bcc_recipients_maps.cf

user = postfixadmin 

password = StrongPasswd 

hosts = localhost 

dbname = postfixadmin 

query = select bcc from bcc_recipients where user = '%s' and active=1;

# vi /etc/postfix/sql/mysql_virtual_bcc_senders_maps.cf

user = postfixadmin

password = 123456 

hosts = localhost 

dbname = postfixadmin 

query = select bcc from bcc_senders where user = '%s' and active=1;

DB tables: CREATE TABLE `bcc_recipients` (   `user` varchar(255) NOT NULL,   `bcc` varchar(255) NOT NULL,   `domain` varchar(255) NOT NULL,   `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',   `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',   `active` tinyint(1) NOT NULL DEFAULT '1' );  CREATE TABLE `bcc_senders` (   `user` varchar(255) NOT NULL,   `bcc` varchar(255) NOT NULL,   `domain` varchar(255) NOT NULL,   `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',   `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',   `active` tinyint(1) NOT NULL DEFAULT '1' );

-----------------------------X_------------------------------------------------------------

# Main.cf   [iredMail]

sender_bcc_maps =

    proxy:mysql:/etc/postfix/mysql/sender_bcc_maps_user.cf

    proxy:mysql:/etc/postfix/mysql/sender_bcc_maps_domain.cf

recipient_bcc_maps =

    proxy:mysql:/etc/postfix/mysql/recipient_bcc_maps_user.cf

    proxy:mysql:/etc/postfix/mysql/recipient_bcc_maps_domain.cf

                        ---------- Creat file -------------

## vi sender_bcc_maps_user.cf

hosts       = 127.0.0.1:3306

user        = vmail

password    = 3UiL7JNph6cHKYfmRltneCNNRfPO1h

dbname      = vmail

query       = SELECT sender_bcc_user.bcc_address FROM sender_bcc_user,domain WHERE sender_bcc_user.username='%s' AND sender_bcc_user.domain='%d' AND sender_bcc_user.domain=domain.domain AND domain.backupmx=0 AND domain.active=1 AND sender_bcc_user.active=1

# vi sender_bcc_maps_domain.cf

hosts       = 127.0.0.1:3306

user        = vmail

password    = 3UiL7JNph6cHKYfmRltneCNNRfPO1h

dbname      = vmail

query       = SELECT bcc_address FROM sender_bcc_domain WHERE domain='%d' AND active=1

# vi recipient_bcc_maps_user.cf

hosts       = 127.0.0.1:3306

user        = vmail

password    = 3UiL7JNph6cHKYfmRltneCNNRfPO1h

dbname      = vmail

query       = SELECT recipient_bcc_user.bcc_address FROM recipient_bcc_user,domain WHERE recipient_bcc_user.username='%s' AND recipient_bcc_user.domain='%d' AND recipient_bcc_user.domain=domain.domain AND domain.backupmx=0 AND domain.active=1 AND recipient_bcc_user.active=1

# vi recipient_bcc_maps_domain.cf

hosts       = 127.0.0.1:3306

user        = vmail

password    = 3UiL7JNph6cHKYfmRltneCNNRfPO1h

dbname      = vmail

query       = SELECT bcc_address FROM recipient_bcc_domain WHERE domain='%d' AND active=1

------