Search code examples
shellunixmailx

mailx UNIX command in one line


What's the best way to send mail from the shell with one line of code?

mailx -s "subject" [email protected]

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" [email protected] \n Body Text \n . 

in one go.

Thank you!


Solution

  • mailx -s "subject" [email protected] <<<$'\n Body Text \n'