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

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 I would like it to simply send from, (set dynamically).

So, for example, if a web app on sends an email, the sender should be, not If a web app on sends an email, the sender should be, etc

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


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 “” sends an email on behalf of “”, an SPF record on 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.


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