Sending mail from command line [Script]

, , Leave a comment


Mail content text is /tmp/message.txt

mail -s 'Server Status Report' [email protected] -c [email protected] < /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” [email protected]

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

Leave a Reply