mailx: invalid option — r

I have a box running on Fedora 13 that does some monitoring. My scripts can send email notifications. I decided to give the sender of these emails proper names, to sort them in outlook and create some rules that move these emails in referencing folders. That works good in Fedora 13. Unfortunately it is not working in RedHat EL5 or higher, because the -r attribute is not known by mail(x). It took me a while to find a way to simulate the -r attribute in these operating systems. By using this syntax mailx is sending emails with a defined from email address.
[root@RH6 ~]# echo -e "Here comes the email body" | mailx -s "The subject of the email" "recipient email address" -- -f "sender email address"
Using this syntax makes it also possible to use other sendmail attributes in mailx. This webpage gives you a good overview of these attributes.

About Juergen Caris

I am 54yo, MSc(Dist) and BSc in Computer Science, German and working as a Senior Server Engineer for the NHS Lothian. I am responsible for the patient management system, called TrakCare. I am a UNIX/Linux guy, working in this sector for more than 20 years now. I am also interested in robotics, microprocessors, system monitoring, Home automation and programming.
This entry was posted in Bash, Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published.