3

I'm setting up postfix to forward e-mails sent to a domain to outside e-mail addresses. i.e. when I get an e-mail at [email protected] it gets sent automatically to [email protected]. That's working except that when I receive the e-mail it shows the recipient at [email protected] instead of [email protected].

I know it's possible to do this because when I had e-mails forwarded using some web panel on a cheapo hosting company, it worked great. So how do I get postfix to retain the recipient address even though it's being forwarded to another address?

My config:

alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases append_dot_mydomain = no biff = no config_directory = /etc/postfix home_mailbox = Maildir/ inet_interfaces = all inet_protocols = all mailbox_command = mailbox_size_limit = 0 mydestination = mydomain.com, localhost.localdomain, localhost myhostname = mx1.mydomain.com mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 myorigin = /etc/mailname readme_directory = no recipient_canonical_maps = hash:/etc/postfix/recipient_canonical recipient_delimiter = + relayhost = [smtp.mandrillapp.com] smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtp_use_tls = yes smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_use_tls = yes 

To be clear, when I receive the e-mail at the forwarded address, I still want it to show the To: address as having the original recipient (@mydomain.com).

1
  • Two questions: [1] What's your current configuration? (please edit the question and post the output of postconf -n command) [2] Which address that do you want to keep? MAIL TO: envelope recipient or To: headers in the message itself? Commented Jun 2, 2015 at 11:38

1 Answer 1

3

Looks like you use this parameter

recipient_canonical_maps = hash:/etc/postfix/recipient_canonical 

to provide mail forwarding. By default Canonical address mapping will rewrite both header and envelope address. So, disable header rewriting, you have two options here

  1. Configure recipient_canonical_classes so recipient_canonical_maps affects envelope address only.

    recipient_canonical_classes = envelope_recipient 
  2. Use virtual_alias_maps that designed for envelope address mapping without touching header.

The virtual_alias_maps option is preferred in this case as you can use it to perform one-to-many mapping. Parameter recipient_canonical_maps only support one-to-one mapping.

2
  • Let me explain what I did. First, I started with virtual_alias_maps, but then I saw repeated warning not to use that with the same domain as my primary domain. In any case, it had the same problem. Next I moved everything to the standard alias_maps and it didn't change anything. Next I tried adding the recipient_canonical_maps, but that didn't change anything either. I meant to remove the recipient_canonical_maps listing in any case, and I certainly need one-to-many mapping. So is there a way to retain the recipient address using the standard alias_maps? Commented Jun 2, 2015 at 15:44
  • Ah, looks like the appropriate config is alias_maps, not virtual_alias_maps. Remember that alias_maps syntax is bit different with both virtual_alias_maps and recipient_canonical_maps. Anyway can you share alias_maps file entry and the exact error message in mail.log? Commented Jun 2, 2015 at 21:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.