E-Mail Forward Domain

Discussion in 'Installation/Configuration' started by LyrX, Nov 21, 2017.

  1. LyrX

    LyrX New Member

    Hi guys,
    I really tried a lot and did so much research, but I'm to stupid to do what i need.
    I have an external mailserver. This mailserver accepts mails for the domain example1.com only. Every other domain is rejected.
    Now I really need a domainalias (example2.com) for the first domain. This cant be done with the other mailserver.
    So I tried zu following: setting MX-Records to my server where ispconfig is running. Configuring and relay-receiver, E-Mail-Transport and content-filter. Relay-Receiver receives the mail, then the filter replaces the domain and then the transport redirects the mail to the right server.
    Receiving and redirecting to the other server working nice. But replacing the domain wont work

    Regex: /@example1.com/
    Data: @example2.com
    Action: Replace

    Whats my fault and what i need to do, to get this working? Watching the manual I bought for ispconfig, didnt help me.
  2. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Looks like you're working towards rewriting mail headers, which may or may not be necessary, but that won't affect the envelope recipient, which is likely what's being rejected by your external server. Try setting recipient_canonical_maps to a map with an entry of
    @example2.com @example1.com
  3. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    I guess if you're unfamiliar with postfix, it's worth saying that you set recipient_canonical_maps in your postfix configuration, eg. edit /etc/postfix/main.cf; point it to a map (eg. 'texthash:/etc/postfix/recipient_canonical_maps.txt'), then add the previous entry to the map itself (eg. create that .txt file and add that).
  4. LyrX

    LyrX New Member

    Okay, I added the following in the end of my main.cf: recipient_canonical_maps = hash:/etc/postfix/recipient_canonical_maps.txt
    This file looks like you said before: @example2.com @example1.com
    Then I did a reload "service postfix reload"
    The Relay-Receiver for example2.com and the routing to the other mailserver is still active.
    I send some mails, but this time nothing happens. No Bounce, but also no mails in Inbox. Just like i never send this mails.

    Can you give me another hint maybe?
  5. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    check your mail log (eg. /var/log/mail.log) and see what gets logged when you send a message
  6. Sergio Cesar

    Sergio Cesar Member

    I am new at ISPconfig3 and not sure this will change with an update but this is how I hacked it:
    Edit /etc/postfix/mysql-virtual_forwardings.cf to look like this:
    comment with a # the lines in italics
    add the query like in bold.
    save the file
    go to the ispconfig manager and add an email forward like:
    Source Destination
    %@domain1.tld @domain2.tld
    user-%@domain1.tld @domain2.tld
    where the % is a wildcard.
    NOTE: domain2.tld does not need to be in the same server, it can be another server somewhere else on the internet.
    I have not fully tested this so your mileage may vary.

    user = ispconfig
    password = blahblahblah
    dbname = dbispconfig
    #table = mail_forwarding
    #select_field = destination
    #where_field = source

    ## additional_conditions = and type != 'aliasdomain' and active = 'y' and server_id = 1
    #additional_conditions = and active = 'y' and server_id = 1
    hosts =

    query = SELECT mail_forwarding.destination FROM mail_forwarding WHERE mail_forwarding.type='forward' AND mail_forwarding.active='y' AND '%s' LIKE mail_forwarding.source
    florian030 likes this.

Share This Page