Change the “From:” address in Unix “mail”

后端 未结 19 2159
萌比男神i
萌比男神i 2020-12-12 14:32

Sending a message from the Unix command line using mail TO_ADDR results in an email from $USER@$HOSTNAME. Is there a way to change the \"From:\" ad

19条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 14:47

    I derived this from all the above answers. Nothing worked for me when I tried each one of them. I did lot of trail and error by combining all the above answers and concluded on this. I am not sure if this works for you but it worked for me on Ununtu 12.04 and RHEL 5.4.

    echo "This is the body of the mail" | mail -s 'This is the subject' ',' -- -F '' -f ''
    

    One can send the mail to any number of people by adding any number of receiver id's and the mail is sent by SenderName from from-id@email.com

    Hope this helps.

提交回复
热议问题