I have a server with Gentoo and Postfix. Postfix is configured so that all e-mail messages are routed through an external relay which requires a particular address in 'From'.
From /etc/postfix/main.cf
:
relayhost = relay.example.com
I also have a cron task, which I'd like to send e-mail from. But the 'From' address is 'user@hostname', which is not allowed on a relay. Is it possible to substitute the correct address to cron for sending messages or fix the Postfix configuration in some way?
I use vixie-cron and ssmtp for a similar situation. What I do, especially for root jobs, is pipe the output of the command through
| mail -r "[email protected]" [email protected]
; it's tedious but it works.