Redirect email without storing on ISPConfig Server

Discussion in 'Installation/Configuration' started by Thomas Tomchak, Jul 25, 2023.

  1. Thomas Tomchak

    Thomas Tomchak New Member HowtoForge Supporter

    I followed this tutorial almost a year ago and got a server up and running on Digital Ocean. Websites, email, the whole thing. I could not have done it without this tutorial.

    I'm really struggling with a problem however that, on the surface, should be crazy simple to do. After working on it for 2 weeks on and off I am at a loss on how to proceed. Hopefully somebody here will know how to fix my issue.

    My goal is to redirect the email for one users mailbox to another server entirely. So the mail comes in, is not stored but is redirected to the other server. The only way I have found that this can be achieved is to write a custom ruile inside that users mailbox settings.

    In the Custom Rules area of that mailbox, I have this code.

    require ["fileinto", "redirect"];

    # Redirect all messages for "[email protected]" to "[email protected]"
    if address :is :localpart "to" "tom" {
    redirect "[email protected]";
    stop; # Stop processing other Sieve rules for this message
    }

    As the email is being processed by the server, it makes the claim that it can not use the redirect command. There appears to be an error with the Sieve script. The error indicates that the redirect action is not recognized as a Sieve capability. This means that the Dovecot Sieve plugin might not be configured properly to handle the redirect action.

    This is where I'm lost. I've learned a lot through this process, but I'm also getting to the point that I just need to get this working again.

    Below is my dovecot.config file contents in case it helps.

    Thanks, and sorry this ended up being so long.

    GNU nano 4.8 /etc/dovecot/dovecot.conf Modified
    # Do not change this file, as changes will be overwritten by any ISPConfig update.
    # Put your custom settings in /usr/local/ispconfig/server/conf-custom/install/dovecot_custom.conf.master.
    # To start using those changes, do a force upgrade and let it reconfigure your services. (ispconfig_update.sh --force)
    listen = *,[::]
    protocols = imap pop3
    auth_mechanisms = plain login
    disable_plaintext_auth = no
    log_timestamp = "%Y-%m-%d %H:%M:%S "
    mail_privileged_group = vmail
    postmaster_address = [email protected]
    ssl_cert = </etc/postfix/smtpd.cert
    ssl_key = </etc/postfix/smtpd.key
    ssl_dh = </etc/dovecot/dh.pem
    ssl_min_protocol = TLSv1.2
    ssl_cipher_list = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY13>
    ssl_prefer_server_ciphers = no
    mail_max_userip_connections = 100
    # previous mail plugin line
    mail_plugins = quota

    # new mail plugin line
    # mail_plugins = $mail_plugins quota sieve

    passdb {
    args = /etc/dovecot/dovecot-sql.conf
    driver = sql
    }
    userdb {
    driver = prefetch
    }
    userdb {
    args = /etc/dovecot/dovecot-sql.conf
    driver = sql
    }
    plugin {
    quota = dict:user::file:/var/vmail/%d/%n/.quotausage

    # no longer needed, as 'sieve' is in userdb extra fields:
    sieve=/var/vmail/%d/%n/.sieve

    sieve_before=/var/vmail/%d/%n/.ispconfig-before.sieve
    sieve_after=/var/vmail/%d/%n/.ispconfig.sieve
    sieve_max_script_size = 2M
    sieve_max_actions = 100
    sieve_max_redirects = 25
    }
    service auth {
    unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
    }
    unix_listener auth-userdb {
    group = vmail
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Do not create that mailbox when you do not want the e-mails stored on your server. Create "Email Forward" in ISPConfig Panel Email tab.
     
    ahrasis likes this.
  3. Thomas Tomchak

    Thomas Tomchak New Member HowtoForge Supporter

    Interesting. I'll have to read more about that. It doesn't make sense to me that you can receive email without there being an email box, but I'll check the manual for more details. I appreciate your answer Taleman.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    That's quite common btw. E.g. you have an email address [email protected] and an address [email protected], both handled by the same person, why should you have two separate imap inboxes for this. Or you change your company domain etc. Or some people have many domains, why do you want to have dozens of imap folders in your mail client, in such a case you simply redirect emails from all domains or addresses to one central inbox. It#s also common for private users that they use a email address e.g. from hotmail for years and want to keep using that and when they make their private website with own domain, they redirect incoming emails to hotmail.
     
    ahrasis likes this.
  5. Thomas Tomchak

    Thomas Tomchak New Member HowtoForge Supporter

    Thank you. I guess it just shows how green I am on this particular topic. But how you just explained it makes more sense. I appreciate your input Till.
     
    till likes this.
  6. Thomas Tomchak

    Thomas Tomchak New Member HowtoForge Supporter

    Just a follow up that your suggestion was exactly what worked. It was a new concept for me to get my head around, having the ability to forward a message that has no mailbox to first receive it

    I appreicate the help.
     
    Gwyneth Llewelyn, Taleman and till like this.

Share This Page