I\'ve created a script that runs every night on my Linux server that uses mysqldump
to back up each of my MySQL databases to .sql files and packages them togeth
metamail has the tool metasend
metasend -f mysqlbackup.sql.gz -t backup@email.com -s Backup -m application/x-gzip -b
Depending on your version of linux it may be called mail. To quote @David above:
mail -s "Backup" -a mysqldbbackup.sql backup@email.com < message.txt
or also:
cat message.txt | mail -s "Backup" -a mysqldbbackup.sql backup@email.com
I use SendEmail, which was created for this scenario. It's packaged for Ubuntu so I assume it's available
sendemail -f sender@some.where -t receiver@some.place -m "Here are your files!" -a file1.jpg file2.zip
http://caspian.dotconf.net/menu/Software/SendEmail/
using mailx command
echo "Message Body Here" | mailx -s "Subject Here" -a file_name user@example.com
using sendmail
#!/bin/ksh
fileToAttach=data.txt
`(echo "To: user@company.com"
echo "Cc: user@company.com"
echo "From: Application"
echo "Subject: your subject"
echo your body
uuencode $fileToAttach $fileToAttach
)| eval /usr/sbin/sendmail -t `;
I use mpack.
mpack -s subject file user@example.com
Unfortunately mpack does not recognize '-' as an alias for stdin. But the following work, and can easily be wrapped in an (shell) alias or a script:
mpack -s subject /dev/stdin loser@example.com < file
From source machine
mysqldump --defaults-extra-file=sql.cnf database | gzip | base64 | mail me@myemail.com
On Destination machine. Save the received mail body as db.sql.gz.b64; then..
base64 -D -i db.sql.gz.b64 | gzip -d | mysql --defaults-extra-file=sql.cnf