Send email from Linux command line

Every once a while you need to send email from a Linux command line and there you go to google try to find it…

With attachment:
[cc lang=”bash” width=”100%”]
echo “message” | mailx -s “subject” -a attachment [email protected]
[/cc]

[cc lang=”bash” width=”100%”]
echo “message” | mutt -s “subject” -a attachment — [email protected]
[/cc]

Without attachment:
[cc lang=”bash” width=”100%”]
echo “message” | mail -s “subject” [email protected]
[/cc]

Important:
Postfix by default restrict attachment size to approx 10MB i.e. 10240000 bytes.

You can check it using following command:
[cc lang=”bash” width=”100%”]
postconf | grep message_size_limit
[/cc]

To change attachment-size to say 50 MB, run a command like:
[cc lang=”bash” width=”100%”]
postconf -e message_size_limit=52428800
[/cc]