Mailuser: "Send copy to" check (not working?)

Discussion in 'Developers' Forum' started by ispcomm, Nov 27, 2013.

  1. ispcomm

    ispcomm Member

    ignore (was: Mailuser: "Send copy to" check (not working?))

    Sorry: Bad call. CC works, but I dont get it how (yet)
    ReEdit: it's dovecot. Sorry. Will leave this for reference.

    I have an issue with the "Send Copy To" parameter in the mail_user table.

    In brief: mail arriving for accounts that have the "send copy to" parameter set receive the mail correctly, but a copy is not sent to the CC address.

    What I did was to put a SendCopyTo on some (many) accounts that had this requirement, via the standard remoting mail_user_add call.

    The value of the CC address is correctly placed in the CC row of the mail_user table.

    Postfix has no reference anywhere to this table. The default virtual_alias_maps looks like this:

    virtual_alias_maps = proxy:mysql:/etc/postfix/, proxy:mysql:/etc/postfix/, hash:/var/lib/mailman/data/virtual-mailman

    The CC field is never used in any of those mysql. The only place (email2email) only references a mail to itself (which is required for postfix):

    table = mail_user
    select_field = email
    where_field = email
    additional_conditions = and postfix = 'y' and server_id = 'X' ;

    Unless there is something very wrong with my install (which I don't think) I guess there's a need for a extra lookup in the mail_user table, with an extra sql query like:

    table = mail_user
    select_field = cc
    where_field = email
    additional_conditions = and postfix = 'y' and server_id = 'X' ;

    Pls. check if this is a correct diagnosis or if I have missed something.

    Last edited: Nov 27, 2013
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no extra lookup needed in postfix, and this function works fine here. The send copy to function is implemented like all other mail filters as sieve / maildrop script, so postfix is not involved directly here.

    Either the data was imported wrong or your setup is not correct and does not comply with the defeult perfect setup or a wrong imap server type or filtering language type is select on your server under system > server config.
  3. ispcomm

    ispcomm Member

    I found the issue: Not all .sieve files were created. I did not notice the 'cc' problem until somebody told me.

    Some mailboxes don't have .sieve. Is there a way for recreating it (sync, remoting api or anything that can be automated) ?
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    A resync will not work as the sieve file creation is only triggered when something changes. Here the code from the plugin:

    if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"]
    			or $data["old"]["move_junk"] != $data["new"]["move_junk"]
    			or $data["old"]["autoresponder_subject"] != $data["new"]["autoresponder_subject"]
    			or $data["old"]["autoresponder_text"] != $data["new"]["autoresponder_text"]
    			or $data["old"]["autoresponder"] != $data["new"]["autoresponder"]
    			or (isset($data["new"]["email"]) and $data["old"]["email"] != $data["new"]["email"])
    			or $data["old"]["autoresponder_start_date"] != $data["new"]["autoresponder_start_date"]
    			or $data["old"]["autoresponder_end_date"] != $data["new"]["autoresponder_end_date"]
    			or $data["old"]["cc"] != $data["new"]["cc"]
    So basically one of the mentioned fields must be changed to trigger the plugin. You could e.g. use the remote api to loop trough all mailboxes and add a comment (starting with #) into the custom mailfilter field as this should be harmless or you save a empty cc field and then set it again, but this will trigger 2 upadtes then so it will take longer.
    Jagrys likes this.
  5. ispcomm

    ispcomm Member

    thank you. I made a small script that calls mail_user_update twice. once with empty CC and once with the original CC. This seems to recreate the .sieve.

    I think that the problem was created by my conversion script and migration from courier to dovecot.

    thank you for helping to find out.

  6. Jagrys

    Jagrys New Member

    Pretty useful information, I changed that line for one resync of mailboxes to $data["new"]["cc"] != '' ... it created all imported `CC`records to appropriate .sieve files

Share This Page