使用mail命令发邮件

Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]
使用管道最为简单,如
echo "This is first email send by shell" |mail -s "first email shell" ***@**.com
-s后面的"first email shell"为该邮件主题
"This is first email send by shell",为该邮件正文

还有一种方法,麻烦些:
首先mail -s "first email shell" ***@**.com,打回车,进入正文编辑
"This is first email send by shell",编写完正文,CTRL+D结束输入,如果需要抄送邮件,后面写入要抄送的邮件地址,否则,直接回车就Ok。

猜你喜欢

转载自y-x.iteye.com/blog/1679874