Hostname not appearing in the forwarded email

I have managed to setup postfix on alma linux 9 to forward email via gmail server but the only problem the name appear to be root. So I change the hostname via this command hostnamectl set-hostname alamtestnet but yet it appears as root in the received emails.

Can you provide the script or one-liner you use to generate the email?
Can you provide an image snippet of what the unwanted result looks like?

That might help us.

This the script I am testing

echo "Test Postfix Gmail SMTP Relay " | mail -s “Postfix Gmail SMTP Relay 1” ****

I would expect to see root@localhost or root@alamtestnet as sender, if you send mail as user root. To see ‘root’ where a hostname is expected – you have to tell more.

It’s been more than a decade since I did this, but if you add “-r” (without the quotes) to the mail command before the “-s” that should set a from address. That from address must be a real address (and domain).

“mail --help” will show the command syntax.

Perhaps one should append to /etc/postfix/generic a mapping, like:


and rehash the map to use:

postmap /etc/postfix/generic

One probably has to add hash:/etc/postfix/generic to smtp_generic_maps in postfix config first.

Overall, postfix should have many options in its config. (The above is the only one that I have had a need for.)