Spedire un messaggio email con attachment da commandline

From RVM Wiki
Jump to navigation Jump to search

Spedire un messaggio text only

echo "This is the message body" | mail -s "This is the Subject" recipient@company.com


Spedire un messaggio text only su più righe

mail -s "This is the Subject" recipient@company.com  <<-END
     This is the message body.
     It can easily accommodate several lines.
     and ${substitutions} work in the here-document.
END


Diagnostica

Per vedere cosa succede:

mail -v .....

Spedire un messaggio con un attachment

echo "Here is the report I promissed: " | uuencode -m -p Attachment.doc | mail -s "This message has an attachment" recipient@company.com

Oppure

(echo "Here is the report I promissed: " | uuencode -m  Attachment.doc Attachment.doc ) | \
mail -s "This message has an attachment" recipient@company.com

Note Attachment.doc as two arguments to uuencode - once as the input file - once as the target filename.

Utilizzare biabam

Installare il pacchetto

apt-get install biabam

Per spedire l'attachment con un messaggio ed un soggetto:

echo Hey, test this ! | biabam gallery2.sql.bz2 -s "Tryout Subject" gabriele.vivinetto@rvmgroup.it

Utilizzo di Mutt

Vedi l'ottimo articolo Sending files as mail attachments

mutt -s "Birthday celebration" -a citymap.jpg all@friends.org \
   	< invitation.txt

Sending files as mail attachments

Expert Exchange: Mail using bash script