ISPConfig 3: How to send copys of incoming emails to other mailboxes

Monday, August 24, 2009 posted by admin

A copy of a incoming email can be sent to a second email address by adding a cc command to the "Custom Rules" field of the mailbox in ISPConfig.

ISPConfig supports sieve as well as maildrop filter rules. The rule language depends on the LDA / POP3 / IMAP-Daemon that you use on your server. If you use courier, then the filter language is maildrop. When dovecot is installed, then the filter language is ieve.

Example in maildrop syntax:

To send a copy to the email address info@example.tld, add the following code at the beginning of the custom rules field.

cc '!info@example.tld'

Example in sieve syntax:

redirect 'info@example.tld';
keep;

Be Sociable, Share!



35 Responses to “ISPConfig 3: How to send copys of incoming emails to other mailboxes”

  1. Giovani says:

    I add in textbox of Custom Rules of email1@mydomain

    cc “!email2@mydomain” and dont work.

    The email1 receice the email but email2 not. What is wrong

  2. admin says:

    Please check in the mail log if the email has been sent. Also make sure that you add the line at the beginning of the rules in case that there are any other filters in this field.

  3. Cuba says:

    work in my server using single quote: cc ‘!email@mydomain.com’, and works if you send email to the “same domain” :S, if I set cc ‘!email@mydomain2.com’ don`t work.

  4. Till says:

    Works for me if the domain is the same or if its a different domain.

  5. Gabriel says:

    Using ISP config 3.0.1.4 with ubuntu 9.04

    - tried both cc “!info@example.tld” and cc ‘!info@example.tld’ = doesn’t work
    – has only that one string in the custom rule field
    – mail log indicates delivery to my domains e-mail but does not forward out to my Gmail
    – sending out from webmail works fine

    I’ll look in the forums and will try to follow up and post in the bug tracker.

  6. Not working at all! I need this feature!

  7. Alex says:

    One problem, just installed ISPConfig 3 and there´s NO “Custom Rules” filed anywhere in the e-mail part. Anyone can help?

  8. Till says:

    @Alex. The custom rules field is on the “Custom Rules” tab of the mailbox form.

  9. Alex says:

    Ok, thx, actually i was trying to manage this rules using the client login, changed to admin and folund it, but, i tryed the commando with double and single quotes, on the same domain, still no success.

    I use CentOS 5.3 i386, my maillog output has no errors, says msgs are queued, but cannot see anything but 0 msgs in queue, using mailq or the iface, can anyone help?

    thx

  10. Alex says:

    Is there any way to debug this? log it?

  11. Alex says:

    So, here´s the solution, updated my installation to version 3.0.1.4, and it worked like a charm using double quotes.

    Thanks 4 everyone, ispconfig seems a great tool

  12. Tomas says:

    ufff, i make this:) working on 3.0.14 and 3.0.15
    manual make file in
    var/vmail/mailfilters/domain.com/user

    file *.mailfilter with
    cc “! mail@anydomain.com

  13. Till says:

    Entering the command into the Custom Rules field does exactly the same. It creates the .mailfilter file with the content of the Custom rules field. So there is no need to edit any files manually in ISPConfig.

    • ldjoha says:

      mailfilters owner is root/root in my system and the subdirectory too. I changed it to vmail/vmail so now its forward mess which I like. I driving Debian 5.3 and ISPConfig 3.0.1.6

  14. SamTzu says:

    v3.0.1.6
    None of the methods above work.
    Quite frustrating.

    Sam

    • Till says:

      These method definatley works. I use it on my own and client servers with all recent ISPConfig 3 versions. Please post what you entered exactly into the custom rules field.

  15. SamTzu says:

    Got it to work.
    The copy/paste from this web page created wrong ”quotes” and thus it failed to work.

    Sam

  16. Peer says:

    Hello!

    First I had problems with this solution. The copy-email didn’t arrived… There was no .mailfilter in var/vmail/mailfilters/domain.com/user … After some tests it worked. The error was that I hadn´t switched on the Spamfilter for that domain at first.

  17. Peter says:

    Hi!

    Which format should be user for multiple e-mail adresses?

    For each e-mail address a single line

    cc “!info1@example.tld”
    cc “!info2@example.tld”

    or comma seperation

    cc “!info1@example.tld,!info2@example.tld”

    ?
    Peter

    • ltvz says:

      cc “!info1@example.tld”
      cc “!info2@example.tld”

      works perfect, but be careful to type directly into ISPConfig yourself and AVOID copy / paste.

  18. Uwe says:

    I have the same problem. I think the prob is, that quotes (“, ‘) are masked with “\”, so in my case in .mailfilter stands: cc: \”!something\”.

    So setting the rule manually without backslash works for me, but this isn’t a nice handling.

    By the way – “custom rules”-tab doesn’t exist in german translation. And maybe in others too?

  19. Matt says:

    I encountered this exact same issue running a clean install of ISPConfig 3.0.1.6 on Debian.

    The only workable solution I found was to manually edit the backslashes out of the /var/vmail/mailfilters/domainname/username/.mailfilter file after creating it thru the ISPConfig control panel. The web interface did indeed create backslashes in that file to escape the quotes, and suspended delivery (syntax errors in the postqueue) for that mailbox as a result.

    Therefore, on a fresh install of 3.0.1.6, it is necessary to manually edit the .mailfilter file to get a copy of the mail forwarded to a different address in my experience.

    My advice to anyone needing this functionality is to use the web interface to create the mailfilter file (by going to the mailbox, then the Custom Rules tab, then typing in cc:”!addressto@forward.to” in there and submitting it), then immediately using SSH or the console to get into the ISPConfig machine and use your favourite text editor to get the backslashes out of the /var/mail/mailfilters/domainname/username/.mailfilter file.

  20. Judge says:

    Just set “magic_quotes_gpc = Off” in php.ini to avoid automatic quotes to be added. Save the rule again after restarting apache and it will work.
    You can check if /var/mail/mailfilters/domainname/username/.mailfilter exists. As soon as you see it, it will work :-)
    Steffen

  21. sam says:

    Custom rules doest not work …..after checking in maillog found there is some problem in sieve….

    Output of Sieve log says..

    #vi /var/vmail/domain/user/.sieve.log

    sieve: info: started log at Jul 16 14:40:59.
    main_script: line 6: error: expected end of command ‘;’ or the beginning of a compound block ‘{‘, but found end of file.
    main_script: error: parse failed.

    OUTPUT of Main script

    #vi /usr/local/ispconfig/server/conf/sieve_filter.master

    require [“fileinto”, “regex”, “vacation”];

    # Move spam to spam folder
    if header :contains “X-Spam-Flag” “YES” {
    fileinto “Junk”;
    # Stop here so that we do not reply on spams
    stop;
    }

    #################################################################
    # Autoreply
    #################################################################

    # Move spam to spam folder
    if header :contains “X-Spam-Flag” “YES” {
    fileinto “Junk”;
    # Stop here so that we do not reply on spams
    stop;
    }
    vacation :days 1
    :subject “Out of office reply”
    # :addresses [“test@test.int”, “till@test.int”]
    “”;

    Plz Help..

    • Till says:

      The custom rule that is described here is for courier pop3/imap server and not for sieve.

      • sam says:

        I’m using the perfect server centos5 64bit configuration using Dovecot

        • Till says:

          And at the time this FAQ article was written (in August 2009), courier was the only supported pop3 and imap daemon. If you use dovecot, then use a sieve rule to redirect your emails. e.g.:

          redirect “my-address@somewhere.else.com”;
          keep;

  22. Maik Heinelt says:

    Hey, thank you for this hack!! It is working like a charm for my ISPConfig 3 installation.
    Just created the .mailfilter file, added the cc “!myaccount@mydomain.com” , and it worked without any issue!

    Thanks, again!

    Maik

  23. Ben says:

    It should be noted that the Sieve syntax in the original post is incorrect in that it uses single-quotes (when it must use double-quotes).

    If single-quotes are used instead of double-quotes, the following parse error results:

    —–
    main_script: line 5: error: unexpected character(s) starting with ”’.
    main_script: line 5: error: expected end of command ‘;’ or the beginning of a compound block ‘{‘, but found unknown characters.
    main_script: line 5: error: unexpected character(s) starting with ‘@’.
    main_script: line 5: error: unexpected character(s) starting with ‘.’.
    main_script: line 5: error: unexpected character(s) starting with ”’.
    main_script: error: parse failed.
    —–

    The correct syntax is as Till stated (be sure to fix any mangled double-quotes if you copy/paste):

    redirect “my-address@somewhere.else.com”;
    keep;

  24. jumbo says:

    Hi Guys,

    is there any script or settings on how to forward email without leaving a copy of message on the main account?

    tried this in custom rule but it still leaving a copy on my main account. please help.

    redirect ‘myname@mydomain.com';
    stop;

  25. Araujo says:

    Can anyone help me? need to get any mail sent to my server containing *.xml and sent a copy to a specific email, but only the emails received and sent a copy to specifed email..thanks..

  26. ismo says:

    Hi jumbo,
    try with this script in custom rules:

    redirect ‘myname@mydomain.com’;
    discard;
    stop;

  27. For those like I who use ISPConfig on Ubuntu server (OVH style) here’s how to get multiple redirections working (yes this is for those using dovecot, as pre-setup via OVH)

    Most important IF you want to redirect to MULTIPLE addresses, when configuring e-mail account in ISPConfig, DO NOT put an e-mail address in the ‘Send copy to’ (optional) box, because this automagically puts an extra line up top in the sieve file and fouls the additional info put in the Custom rules tab (in my version of ISPConfig, french language, the tab is ‘Regles personalisés’).

    In the Custom rules (tab on the right), simply input :

    redirect “user1@a-domain.tld”;
    redirect “another.dude@anotherdomaine.tld”;
    redirect “yet.another.guy@thisdomain.tld”;
    redirect “how.bout.a.gal@foo.com”;
    keep;

    You can put as many redirects as needed. BTW, double quotes work just fine

    You can checkout your .sieve file (in /var/vmail/domain.tld/user/ ) to see changes : but give ISPConfig 60 seconds to do the changes ( remember that it crons changes once a minute.)

    Hope this helps.

  28. Bogdan says:

    Hello,
    Haw I can make a custom rule for forwarding emails received from specific addresses to other address?
    ISPCONFIG 3 on Ubuntu 12.04
    Thank you.
    Bogdan

Leave a Reply