Dear all,
Recently I have set up mail server using Postfix and Dovecot
Some of the accounts had to be bcc'ed to more than one account, and 
recipient_bcc_maps doesn't allow that
As an alternative, when email is received the server makes a bcc to <account 
id>@duplicator.localhost
When email is received for @duplicator.localhost, virtual_alias_maps forwards 
the email to all accounts specified for the current recipient's id (using 
mysql).
Irrelevant to the above, just fyi: there is one more rule in the 
virtual_alias_maps, that if receiver's domain is not duplicator.localhost, then 
checks whether the current account is of 'mailbox' or 'forwarding' type. First 
one means do nothing, because it should be bcc'ed to duplicator.localhost 
first, and the second one means that it will not be bcc'ed to 
@duplicator.localhost, but all specified addresses should be used to directly 
forward the received email to.
This is the configuration
recipient_bcc_maps = 
mysql:/etc/postfix/sqlconf/recipient_bcc_maps.cfvirtual_alias_maps = 
mysql:/etc/postfix/sqlconf/virtual_alias_maps.cf
recipient_bcc_maps.cf:
 user            = vmail password        = xyz dbname          = mails query    
       = SELECT concat(u.id,'@duplicator.localhost') FROM users u WHERE 
u.username='%u' AND u.domain='%d' AND u.active='1' and u.type=0 /* 0=mailbox; 
1=forwarding */ limit 1; hosts           = 127.0.0.1                    
virtual_alias_maps.cf:
 user            = vmail password        = xyz dbname          = mails query    
       =       SELECT n.address                         FROM users u            
             LEFT JOIN next n ON n.id = u.id                         WHERE ( 
u.active = '1' ) /* u.active = 1 means that the account is in use, otherwise it 
is disabled */                               AND                               
(                                 (                                         
'%d'      !=  'duplicator.localhost'                                   AND   
u.type     =  1                                   AND   u.username =  '%u'      
                             AND   u.domain   =  '%d'                           
      )                                 OR                                 (    
                                     '%d'       =  'duplicator.localhost'       
                            AND   u.id       =  '%u'                            
     )                               ); hosts           = 127.0.0.1
This setup works fine up to here with one exception I am trying to fix. When 
the email is forwarded by virtual_alias_maps to some (mailbox type) account, it 
is not bcc'ed further to @duplicator.localhost. Probably this happens because 
the email header of the forwarded email doesn't contain the current account as 
recipient.. Is there any way to rewrite the bcc field when forwarding an e-mail 
using virtual_alias_maps to include the current receiving account as recipient? 
I looked into recipient_canonical_maps, but it doesn't seem to allow bcc 
rewriting..
Best regards,JC                                           

Reply via email to