mailx -s "subject" foo@bar.com <<<$'\n Body Text \n'
mailx UNIX command in one line [duplicate]
题
What's the best way to send mail from the shell with one line of code?
mailx -s "subject" foo@bar.com
Enters into line by line entry of the body and the message is only sent with termination of Ctrl+D or '.'
Since I am accessing the system command through another program, I'd like to be able to do something like:
mailx -s "subject" foo@bar.com \n Body Text \n .
in one go.
Thank you!
解决方案
其他提示
Thank you to both Alfe and Joachim PileBorg, I now have two solutions! The one Alfe provided works, as does:
echo "body" | mailx -s "subject" foo@bar.com
which, though my Unix is rusty, I imagine does basically the same thing.
不隶属于 StackOverflow