Send email from Linux command line

By | March 13, 2015

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:

echo "message" | mailx -s "subject" -a attachment [email protected]
echo "message" | mutt -s "subject" -a attachment -- [email protected]

Without attachment:

echo "message" | mail -s "subject" [email protected]

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

You can check it using following command:

postconf | grep message_size_limit

To change attachment-size to say 50 MB, run a command like:

postconf -e message_size_limit=52428800