Sending a mail from a linux shell script

后端 未结 11 2066
一个人的身影
一个人的身影 2020-12-04 06:52

I want to send an email from a Linux Shell script. What is the standard command to do this and do I need to set up any special server names?

11条回答
  •  庸人自扰
    2020-12-04 07:39

    Admitting you want to use some smtp server, you can do:

    export SUBJECT=some_subject
    export smtp=somehost:someport
    export EMAIL=someaccount@somedomain
    echo "some message" | mailx -s "$SUBJECT" "$EMAIL"
    

    Change somehost, someport, and someaccount@somedomain to actual values that you would use. No encryption and no authentication is performed in this example.

提交回复
热议问题