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" [email protected] -- -r "[email protected]"

Use echo to send your emails

echo -e "TEST\n.\n" | mail -s "subject" [email protected] -- -r "[email protected]"

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

Use a file as the contents of your email

mail -s "subject" [email protected] -- -r "[email protected]" < /tmp/email