Postfix - Send mail "from" originating domain rather than static server domain

SYSTEM INFORMATION
OS type and version: Ubuntu 16.04
Webmin version: 1.973
Virtualmin version: 6.16

Is it possible to configure postfix to set the envelope From/Sender field to the virtualhost domain from which the email originates? In my current config, it sends from mail.myserver.com. I would like it to simply send from my-virtualhost-domain.com, (set dynamically).

So, for example, if a web app on vhost1.com sends an email, the sender should be vhost1.com, not mail.myserver.com. If a web app on vhost2.com sends an email, the sender should be vhost2.com, etc

The reason for this is that I would like to eliminate the “sent via mail.myserver.com” messages and also reduce false spam flags by setting SPF per virtualhost domain.

Possible?

You would need to configure that on the web app itself.

For example, in WordPress, you would make changes to the wp_mail() function and in a vanilla PHP app, you would make changes to the mail() function.

No, not if you comply with RFCs.

I fully assumed this was a postfix config issue and it never occurred to me that the sender header could be set before getting to postfix.

Most of the websites facing these issues are Wordpress. I’ll look into this, thanks.

Maybe I’m just trying to accomplish the wrong thing. The problem is that when “mail.myserver.com” sends an email on behalf of “vhost1.com”, an SPF record on mail.myserver.com isn’t enough to pacify many spam filters, Office365 in particular.

If anyone has any suggestions, I’d love to hear them.

That’s correct. An RDNS for mail.server.tld must be in place and DKIM for the domain which sends mail via mail.server.tld.

The IP address should not be recently blacklisted. The IP block to which the IP address belongs should not be tainted and it helps if a few (hundred or thousand) recipients specifically whitelist the email address from which mail is being sent; or at least add it to their address books.

I’ll look into using DKIM with Virtualmin.

Thanks!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.