1

I need some serious help guys. I am fairly new to postfix but have spent countless hours researching about my question. Let me cut to the chase...

I would appreciate your responses entirely and please do your best to explain the steps in dummy language.

Rationale: I want ALL bounce emails to go to my IMAP bounce address (e.g. [email protected]). The problem is bounce messages are returned to the address found in the Postfix sender envelope (MAIL FROM) ([email protected]). This is my fully qualified domain name for the Postfix mail server.

Postfix then delivers bounce messages locally as confirmed in the vmail mailbox.

However, I dont want this log to be clogged with bounce data. It makes no logical sense since I am not using Postfix for IMAP or receiving messages. I am only using Postfix dedicated specifically for sending OUTGOING emails.

All my Incoming messages/IMAP happen at my mailbox at Namecheap. If anyone replies to my emails it gets delivered to that zone since I have a Namecheap MX record in my DNS.

All ISPs will always return bounce email messages to the sender envelope MAIL FROM address not the return path in the header. As a point of clarification my return path header is [email protected]. As such, I want this domain to match the sender envelope.

I also plan on using my Postfix mail server to send emails from another domain (e.g. [email protected]

So, I would like the second domain to match the sender envelope whenever there's a bounced email.

Solution Canonical? After reading several threads, like this one, it seems the common answer would be to use a regexp canonical_maps and canonical_classes.

However, I am completely lost on what expressions I would input in the /etc/postfix/canonical file based on my use case.

Can anyone please tell me specifically how to write these expressions based on the aforementioned? Please dont point me to postfix documentation, especially on this topic, because I have already completed this step. All it did was leave me in a sea of confusion.

In retrospect, I want an expression that tells Postfix to automatically rewrite the sender envelope for multiple domains to match the header return path email. For example:

  1. I send bulk emails from [email protected]. Some emails bounce. I want the sender envelope to show [email protected] so I can receive the bounce email in my Namecheap mailbox.

  2. I also send bulk emails from another domain [email protected]. I want the same setup as number #1 above.

That way, Postfix mail server will never receive these message further consuming system resources and hard drive storage.

If it helps, I tried chatgpt but I dont think the answer is accurate. It told me to paste this code in the canonical file:

/^(joe@news\.mydomain\.com)$/    [email protected]
/^(joe@news\.mydomain2\.com)$/   [email protected]

Does this look correct in your expert eyes?

Repercussions?

My last question and it is quite an important one: are there any repercussions for changing the sender envelope? Will ISPs mark my emails as spam?

I noticed my sender envelope address for bounces is [email protected], which is the default for Postfix.

According to this thread which says, "I should leave double-bounce to the default. With postfix, setting it to a valid address would create transport loops. Changing the default breaks internal workings and spam filters, spamassassin rules among others. It can also potentially land you in more blacklists."

So if this the case, why have so many postfix users changed the sender envelope using canonical maps without any problems? I dont understand how it can land you into more blacklists if Postfix already gives you the flexibility to change the email. Why would Postfix do that if there are serious repercussions?

I am not sure if I can do this, but I am willing to compensate anyone who takes the time to respond with enough detail helping find a workable solution!

Sorry for the long write up. I was trying to be very detailed so that I can hopefully get a productive response and help anyone else facing the same dilemma.

Thank you immensely!

1 Answer 1

0

(This should arguably be a comment, but its to long and requires to much formatting)

I'm not certain I can help with this (I don't think I understand your setup well enough, and probably lack some required knowledge) - There is also a lot to unpack and this might be an XY question.

The chatgpt outout does not look quite correct. I'd try

  /@smtp\.mydomain\.com/i        [email protected]
  /@smtp\.mydomain2\.com/i       [email protected]

The above should send any email destined for *@smtp.mydomain.com and send it on to [email protected] (which will catch [email protected] and [email protected]) and similarly for mydomain2.com.

The regex is quite simple here - The parts between the "/" characters are what are searched. The "." character is specifically matched by "." as "." in a regex expression means "any character", so to match "." you escape it by putting a "" behind it. The "i" at the end of the first column means do a case insensive search. The second column is where matches should be forwarded to.

I've left out the ^ (start of line) and $ (end of line) so my matches would be looser. I imagine it would not hurt to throw these in.

(I believe chatgpt is wrong because they have brackets in the left side, which means "identify this as a term", and they are then using that term in the right side with $1 - so email going to [email protected] will redirect to [email protected]@smtp.mydomain.com)

If you do need something that pulls out the user - ie if there will be people other then yourself that need bounce messages the following might work - but its beyond what I've needed to do in postfix.

 /^(.*)@mydomain\.com$/i          [email protected]
 /^(.*)@mydomain2\.com$/i         [email protected]

I think you are overthinking the repercussions. The only entities in the path relate to you, so you won't find yourself in any spam traps other then conceivably one at Namecheap - but the risk would seem the same however you address this.

Thinking about examining the envelope vs from - this may be a bit out my depth but I imagine you actually don't want to use the address in the envelope because it could be faked, and I posit may be used to send spam.

1
  • thank you David again. I really appreciate you taking the time to answer every question with enough details. Yes, I believe so too chatgpt is wrong per my research the last few days on those entries. One small clarification. I am using the same SMTP server my both domains. Both domains will share the smtp.mydomain.com mail server. So this entry: /@smtp\.mydomain2\.com/i.....should read.... /@smtp\.mydomain\.com/i. So would this be correct????: /^(.*)@mydomain\.com$/[email protected].... /^(.*)@mydomain\.com$/[email protected] Commented Sep 29, 2023 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .