I'm implementing a script to backup my MySQL database. All process is OK and I send an email when it finish. But I want to attach the file in that email and I don't know how to do it.
My command line is:
mail -s "$1" -a "MIME-Version: 1.0;" -a "Content-type: text/html;" root@$domain -c [email protected] < $2
Where $1 = My subject
and $2 = my message body
Thanks!
You are very close. You can use
mail
command to send 1 attachment as follow (you'd better TAR / ZIP your files before sending):Next, if you want to have more features, you can use
mutt
(install withapt-get install mutt
):where:
or use
uuencode
(install withapt-get install sharutils
):Note:
file.tar.gz
twice (read uuencode documentation for more information)mailx
is a newer version ofmail
, but still an ancient commandto send multiple attachments with
mail
command (well, if you insist):Hope the above helps.