Thursday, April 22, 2010

Sending an e-mail with attachment using mutt command line interface

Sending an e-mail message with an attachment file using command line interface is a useful operation. It is a convenient way, say, to backup some small files.

$> echo "Hello! This is a backup." | mutt -s "backup" -a '/tmp/backup.tgz' -- 'mail@example.com'

This command sends an e-mail message with a body specified as an argument of echo command ("Hello! This is a backup.").

The subject of an e-mail is given with -s argument (-s "backup").

Attachment is specified with -a option (-a '/tmp/backup.tgz').

Be sure to specify two dashes (--) before an e-mail address ('mail@example.com'), otherwise you get "No recipients specified." message on some systems.

No comments:

Post a Comment