UNIX / Linux : Send mail with attachment using mutt

What is mutt

Mutt is a text-based mail client. Mutt is known for being a fast and highly configurable mail client, and since it is text-based, it’s ideal for checking email quickly over SSH.

Installing mutt

To install mutt using yum :

# yum install mutt
...
========================================================================================
 Package            Arch         Version                             Repository    Size
========================================================================================
Installing:
 mutt               x86_64       5:1.5.21-26.el7                     basecd       1.4 M
Installing for dependencies:
 mailcap            noarch       2.1.41-2.el7                        basecd        31 k
 tokyocabinet       x86_64       1.4.48-3.el7                        basecd       459 k
 urlview            x86_64       0.9-15.20121210git6cfcad.el7        basecd        27 k

Transaction Summary
========================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 1.9 M
Installed size: 7.3 M
Is this ok [y/d/N]:y

Sending mail with attachment

Mail can be sent with large message body and attachment using mutt tool.

1. Use mutt command in following format to specify subject, message body and attachment to send mail from command line.

# echo "" | mutt -s "subject" -i body.txt -a attachment.txt recipient@example.com
-s used to specify subject of mail.
-i used to specify file containing message body.
-a used to specify attachment file.

Some other commonly used options with mutt are:

-b used to add Bcc address.
-c used to add Cc address.
-e if you want to specify sender's address (something other than default).
Related Post