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

后端 未结 19 2160
萌比男神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:49

    I don't know if it's the same with other OS, but in OpenBSD, the mail command has this syntax:

    mail to-addr ... -sendmail-options ...
    

    sendmail has -f option where you indicate the email address for the FROM: field. The following command works for me.

    mail recepient@example.com -f from@example.com
    

提交回复
热议问题