Postfix relay: Return-Path

Hey.

I’ve setup postfix mail relay from my “main server” to my “mail server”. SPK, DKIMM, DMARC etc is all working as expected, but gmail still thinks I’m sending mail from my “main server”. For example, I’m seeing: “mailed-by: my.mainserver.tld” and I think this is contributing to some messages being marked as spam.

It looks like postfix is adding a “Return-Path: <www-data@my.mainserver.tld>” and I think this is why gmail thinks I’m sending mail from my “main server” instead of my “mail server”.

When I send these test emails, the “From:” header is explicitly set, so I don’t understand why postfix is adding a different return-path. Anyone got any suggestions?

Thanks in advance.

Return-Path is typically added by the final MTA, in this case Gmail. Before the message hits the final MTA, the value is carried along in the SMTP protocol’s MAIL FROM command separately from the message content (MIME).

This value is coming from whatever is first submitting the message, in its MAIL FROM command. How this is set depends on how you are submitting the message initially.

With the current version of Mail-in-a-Box, the box will only permit relaying MAIL FROM addresses that the user connecting to the box is authorized to use (the user’s username itself, or an address permitted on the aliases page). Are you using the current version? That should prevent these problems.

Hey, thanks for the reply. I got this working by changing the envelope sender on the sending server, see here: http://serverfault.com/questions/533912/how-do-i-change-the-envelope-from-in-postfix/584649#584649

With that change, gmail is now showing the correct Return-Path.

But the Received: from and Received: by headers were still showing the sending server hostname, not my mail servers’ hostname. So to resolve that I changed the myhostname in /etc/postfix/main.cf to match the mail servers hostname.

With those two changes, my sending servers’ hostname is completely removed from the emails.

I’m unsure if changing the postfix hostname on my main server to match the mail servers hostname is a good thing though…

Actually in the end I decided changing the hostname is not a good idea. Just changing the sender envelope seems to be good enough for gmail to show the correct “mailed-by:” hostname.