Sending mail from command line [Script]

Sending mail from command line [Script]



Mail content text is /tmp/message.txt

mail -s 'Server Status Report' george@example.com -c Jon@example.com < /tmp/message.txt

Sending mail with attachment

# !/bin/bash
tar -zcf /tmp/backup.tar.gz /home/david/files
echo | mutt -a /tmp/backup.tar.gz -s “daily backup of data” Jon@example.com

Sending mail (another example)

echo 'GPS Server ALERT - Root shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" Jon@example.com

Leave a Reply

Your email address will not be published. Required fields are marked *