• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Change hostname for outgoing mail with MSMTP

Toxalot

Basic Pleskian
I'm using Plesk on a web host that blocks port 25. So I have moved mail to an external service and set up MSMTP.

The issue I'm having is that I just discovered that the mail service doesn't allow me to send from subdomains. The Plesk hostname is vps.mydomain.net and I know changing the hostname can be problematic. I really don't want to do that.

However, I was wondering if there is some config I can change somewhere that would change the hostname just for outgoing mail. I don't need or want the outgoing domain to match the subscription domain. I need to use the same domain for all outgoing mail, but it must be a bare domain. No subdomain.

I was in final testing after migrating mail to a new service. I really don't want to move yet again. I also would prefer to keep all mail in the same place and not sign up for yet another service just for outgoing mail. I'm trying to find the simplest way to get this working.

Can I change the hostname that MSMTP uses in envelope FROM? If so, will that change be persistent? As in, is there a Plesk-safe way to make that change?
 
Here's what I've learned so far. The config file is /etc/msmtprc but that file is replaced anytime the settings are changed via the control panel. Even if I could prevent anyone from doing that, I'm not sure what else might overwrite that file.

That file is created by the msmtp utility which is /usr/local/psa/admin/sbin/msmtpmng

I made a change to that file and it does what I need, but I have no idea what might overwrite that file. I figure there is less chance of the utility file being overwritten than the config file. We'll see. It works for now.
 
It's been a while since I've used MSMTP, but from what I remember it has limited options for custom configuration. And, as you've already discovered, Plesk overwrites any configuration up on saving/changing the settings in the control panel (and probably on updates too).

Wouldn't you be better off using Postfix? Which you can also configure to relay any messages to any external mail service. With the additional benefit that Postfix has way more options you can configure and customize.

Have a look at this support article on how to setup Postfix to relay messages via SendGrid. Which might not be the ESP you're using, but it hopefully gives some insight in how to get started with Postfix. https://support.plesk.com/hc/en-us/articles/115004060494
 
That article was one of the first I found in my research. But it has a big warning about changes getting overwritten. So six of one, half a dozen of the other. And now that I've moved all incoming and outgoing mail to a separate service, I'd rather not run a mail server. It's confusing for users to have a mail link in the control panel that doesn't manage mail. If only my predecessor had migrated to a server that met our needs. Sigh.

There doesn't seem to be a Plesk-safe way of doing what I need. I've found relevant UserVoice suggestions, but all of them are years old with no traction.
 
Yeah, fully safe options for using external mail services on Plesk are dire.

There is a risk that Plesk updates might overwrite the Posfix settings. However I use a custom Postfix config on a number of my servers and so far none of them have ever been overwritten. A few times Plesk modified the config file on updates with additional settings, but thats about it. (Knock on wood).
 
I've run into this. The default needs to be setting auto_from to off in the msmtp config file, or allow UI configuration of this setting. i.e.:

# Automatic envelope-from generation.
# Caution: this overrides explicitly set envelope-from via --from or other means.
auto_from off

Really does anyone who is using msmtp want the return-path set to [email protected]?
 
Apparently, auto_from is now obsolete. I changed allow_from_override from off to on in the msmtp config file to fix the issue.

# Automatic envelope-from generation.
# Caution: this overrides explicitly set envelope-from via --from or other means.
from %U@some-silly-nonsense-default
allow_from_override on

I "locked" the file to prevent Plesk from being able to overwrite it - must be root:
chattr +i /etc/msmtprc

It seems to prevent Plesk from modifying it. Attempting to update the settings in the Plesk panel results in this:
Image 002.jpg

To unlock the file , use:
chattr +i /etc/msmtprc
 
Back
Top