postfix snippets

How to send emails from the command line in Linux

Tagged mail, postfix, smtp  Languages 

Use the mail command...

Specify the sender with the -r switch

mail -s "Yer subject" -- -r ""

Use echo to send your emails

echo -e "TEST\n.\n" | mail -s "subject" -- -r ""

Note that we use the -e switch to preserve new lines.

Use a file as the contents of your email

mail -s "subject" -- -r "" < /tmp/email