How to include a display name when sending mail with mailx
1
vote
1
answer
1017
views
I'm sending email from a script using mailx. The script is run daily by systemd, using .service and .timer files. For testing purposes I'm sending from the command line.
The mail is sent with the command
echo "Test message - you know the drill" | mailx -r "localweb@example.uk" -s "Test Message" a.user@example.com
(personal data replaced for privacy)
This works. It's relayed by postfix to my gateway server (also postfix) which signs the outgoing message. This is then delivered to GMail which verifies the SPF data and DKIM signature, and the message is delivered to my inbox.
This is good, except it's displayed as
Ubuntu
I have other servers sending mail by the same method, and they all display similarly.
I'd like to change the display name to something more useful, per server. For example, Web Server
but something I'm doing is messing up the From
address as it travels to the gateway server.
I've tried
echo "Test message - you know the drill" | mailx -r "Web Server localweb@example.uk" -s "Test Message" a.user@example.com
and
echo "Test message - you know the drill" | mailx -r "Web Server " -s "Test Message" a.user@example.com
But in both cases the From address is somehow lost by the local PostFix, and the message sent to the gateway server has a from
address of localweb@smtp.private.example.uk
where smtp.private.example.uk
is the FQDN of the gateway server. This is sent to GMail, but fails the SPF and DKIM tests and is unceremoniously dumped in spam as a result. (I don't know how the local postfix is getting the name of the gateway server)
So, how can I add the display name to the parameters I pass to mailx such that it survives the journey from server to server and is displayed correctly by GMail?
Mailx version 3.14 (GNU Mailutils)
Ubuntu 22.04
I've made only one change to main.cf
for PostFix: added a relay-host address for the gateway server.
Asked by CatchAsCatchCan
(113 rep)
Sep 4, 2023, 08:40 AM
Last activity: Sep 4, 2023, 10:14 PM
Last activity: Sep 4, 2023, 10:14 PM