Outbound mail showing wrong email address

I have setup my mail server and it sends and receives mail fine with one exception. The outbound mail address shows the wrong domain.

I have played with the setting “What domain to use in outbound mail”, but it doesn’t work the way I expect.

Here is the scenario:

I created a new virtualhost for the domain acmecorp.com (apologies to the real acme corp). Users are test1@acmecorp.com etc.

When sending out mail with the selection in "What domain to use in outbound mail" set to hostname the users email address looks like test1.acmecorp@mailserver.myhostdomain.com (using myhostdomain.com in place of my real domain name)

If I move to the domainname setting it sends mail from test1.acmecorp@myhostname.com. That is progress but is still not accurate.

What am I missing here? (All test messages are generated in Usermin.)

Thanks

So, first up, let me mention that the mail client usually sets the outgoing From: address. So, Thunderbird, Outlook, etc. are responsible for the outgoing address.

That said, if you’re sending from an application on the server, and it doesn’t know how to set the From: address (pretty rare, and pretty weird, but OK), you can use canonical maps to have Postfix reset the from field. More on that below, but I want to stop you from going down dead ends first:

I have played with the setting "What domain to use in outbound mail", but it doesn't work the way I expect.

This is always a nonsensical setting in a virtual hosting environment…it can’t possibly have a good effect. In a virtual hosting environment there could be hundreds of domains to use in outbound mail…how could one name ever be the right path? :wink:

It shouldn’t be set to anything.

You can’t set this on a server-wide basis for virtual hosting…which is what you’re doing with those settings. They should remain at defaults (which is basically letting Postfix figure it out on its own).

So, make sure those are at their defaults. They can interfere with mail clients that do set the From: field correctly, and they can interfere with delivery and other stuff. They’re just bad news, so don’t mess with them.

What you do want, assuming you can’t configure the sending clients to correctly set the From: address, is to enable canonical maps in Virtualmin and Postfix. This can be turned on in Module Config->Server Settings->Also update outgoing addresses for mailboxes?

I don’t think this will instantly add canonical maps for all mailboxes…so you’ll need to update the ones that are not sending with clients that can set a From: address correctly (just edit it and save it with no changes should add the canonical map, I think). Or, if you must update for everyone, there’s probably a way to do it with the “virtualmin modify-user” command…I’ll ask Jamie to chime in with how that can be done safely (without deleting the mail user and recreating, for example).

I guess I should have mentioned I tried setting the outbound to nothing by leaving the field blank and it will not allow that. So what is the trick to nothing for this? Should I just remove it or comment the line in the config file?

The answer really depends on what program is sending email - is this Usermin, a mail client like Outlook, or your own script? Only in the last case do you need to setup outgoing address mapping (canonical maps) in Virtualmin, and even then you can typically have your script set a from address explicitly.

So if the setting is defaulted to anything, the client should over write it. For my testing purposes in Usermin I can set the Reply-to address manually.

What ever client we use – a web variant or Thunderbird/outlook, your expectation is that it will use the email address entered in the configuration wizard. Correct?

So in a default Virtualmin install using our scripts, Usermin should be setup to get the From address automatically for each user from the /etc/postfix/virtual file.

For mail clients like Outlook or Thunderbird, the address is completely configured by the user.

Yep, that seems to work fine. Thanks

May I ask where can I get this script? This is also a problem I’m having with my install of postfix.

Only difference is when I enable "Also update outgoing addresses for mailboxes?" I get this error.

“No sender canonical map file for outgoing addresses was found in your Postfix configuration. You should either add the appropriate map to Postfix, or disable this feature in Virtualmin’s module config page.”

Would appreciate your assistance. Thanks in advance.

May I ask where can I get this script?

install.sh is on the Download page, linked in the menu of every single page on the site, both at the top and the bottom of the page. I can’t imagine how we could possible make it easier to fine. :wink:

But, note that if you’re already in production (i.e. you have users and virtual servers and they are in use) it is not generally safe to use install.sh.

We do, however, always recommend you install using the install.sh script, if you are using any supported OS (and if you aren’t using a supported OS, we generally recommend you switch to one…not because we don’t like all the other Linux distros, and such, but because the supported systems, particularly Grade A support systems, have a lot more testing and are known to work well for virtual hosting).