Sending email with attachment from the command lineThe following one-liner sends email with attachment straight from the command line:
echo 'Here is the report from yesterday.' | uuencode /tmp/report.txt report-yesterday.txt | mail -s 'Report from yesterday' firstname.lastname@example.org
What does it do: sends an email to email@example.com with subject 'Report from yesterday'; the body contains 'Here is the report from yesterday.' and one attachment - report-yesterday.txt with identical content as /tmp/report.txt.
You will find this very useful when creating reports, summaries and even backups with automated cronjob for example.
No comments yet
This page was last modified on 2017-03-26 16:28:38