Changing default mail "from address"

Hi,
Using Leap 15.4 and Postfix 3.5.9 and mail 12.5.
I am trying to get my email server to send emails from system and cron jobs etc. and via the CLI . However, unless I specify the “-r” from address parameter in the scriptfile for the mail command they are bounced, as the emails are from root or user. I need to set a default from address such as user.name@ispnetwork.com. I have looked at the output of info mail and I see reference in the -r address information and it refers to environment or startup variables.

Typical error message is:-
2022-12-26T15:46:55.848604+00:00 venus postfix/qmgr[13107]: CBE4B6F400B: from=root@ntlworld.com, size=414, nrcpt=1 (queue active)
2022-12-26T15:46:57.312754+00:00 venus postfix/smtp[22026]: CBE4B6F400B: to=user@gmail.com, relay=smtp.ntlworld.com[212.54.56.52]:25, delay=1.5, delays=0.03/0.01/0.33/1.1, dsn=5.1.0, status=bounced (host smtp.ntlworld.com[212.54.56.52] said: 550 5.1.0 From address is invalid (VM402) (in reply to MAIL FROM command))

Can someone help with telling what variable to set and how.

Regards

John

Hi
Edit the /etc/postfix/aliases file, then run the command newaliases.

Hi Malcom,
Tried that early on and apparently it only works for “local delivery”. I did set root to user.name@ispnetwork.com in the alias file and ran newaliases - no luck. The log file still shows root

John

Hi, has the alias map been set? Run postconf alias_maps

venus:/etc # postconf alias_maps
alias_maps = lmdb:/etc/aliases

so it looks to be ok.
AND
/etc/postfix/aliases contains
“# Person who should get root’s mail. Don’t receive mail as root!”
root: user.name@ispnetwork.com

thanks

Some nice reading: Postfix Address Rewriting

BTW: I have no idea why you won’t use mail -r. Can you explain?

Hi, so it’s pointing to a different aliases file… /etc/aliases update that one not /etc/postfix/aliases

Hi Karl,
I have indeed edited as many script files I can find and added the -r parameter. I wanted the system to send any system email to me and wanted a system wide setting.

Hi,
I updated /etc/aliases and re-ran newaliases, restarted postfix - no improvement

thanks
John

Hi Karl,
I used Generic mapping and success it seems to be working.
I added
smtp_generic_maps = lmdb:/etc/postfix/generic to main.cf
I added
root user.name@ispnetwork.com to /etc/postfix/generic

then ran
postmap /etc/postfix/generic - as instructed in the text

Restarted postfix and it worked. (had to dig it out of spam but now works)
I will see what if any errors I get

Many thanks to both yourself and Malcolm

Regards

John

Thanks for the feedback. Postfix documentation is terse, but accurate: Postfix Address Rewriting