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

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

    On Debian 7 I was still unable to correctly set the sender address using answers from this question, (would always be the hostname of the server) but resolved it this way.

    Install heirloom-mailx

    apt-get install heirloom-mailx
    

    ensure it's the default.

    update-alternatives --config mailx
    

    Compose a message.

    mail -s "Testing from & replyto" -r "sender " -S replyto="sender@example.com" recipient@example.net < <(echo "Test message")
    

提交回复
热议问题