facebook youtube pinterest twitter reddit whatsapp instagram

Send Mail with Attachment Using Mutt in GNU/Linux

I have tried a couple of programs to send mail in my GNU/Linux system, and I'll be honest, the majority of them are clunky to use, not until I tried Mutt.

Mutt is a powerful text-based mail client for Unix or GNU/Linux operating systems. It features:

  • color support
  • message threading
  • MIME support (including RFC2047 support for encoded headers)
  • various features to support mailing lists, including list-reply
  • POP3 support
  • IMAP support
  • full control of message headers when composing
  • highly customizable, including keybindings and macros
  • change configuration automatically based on recipients, current folder, etc.
  • searches using regular expressions, including an internal pattern matching language
  • easily include attachments when composing, even from the command line
  • ability to specify alternate addresses for recognition of mail forwarded from other accounts, with ability to set the From: headers on replies/etc. accordingly
  • multiple message tagging
  • reply to or forward multiple messages at once
  • small and efficient
  • It's free! (no cost and GPL'ed)
  • and many more

Install mutt using:

sudo apt install mutt

To get started, simply enter 'mutt', if you don't already have a mailbox in place it would show:

/home/user/Mail does not exist. Create it? ([yes]/no):

Click y if you want it to create a mailbox for your user, and you should see something as follows:

1. Mutt mailbox

To view your root mailbox, simply enter 'sudo mutt', and if a mailbox is available you'll see something as follows:

2. Root mailbox

Sending Mail With mutt

There are a couple of ways you could send a mail with mutt, you can either use the text-based interface or use it directly in your shell, I'll show you both ways:

To send mail via the interface, use the following steps:

  1. Type m in your keyboard, and beneath the interface you'll see a "To:" enter the address you which to send email to
  2. Enter Subject, hit Enter and you'll be taken to your editor, this is where you would compose the message. Compose your message and save
  3. To send the mail, simply type y

To send it via the command line, you do the following:

echo "" | mutt -s "subject" -i body.txt recipient@example.com

-s flag is used to specify the subject line of the email Also, -a flag is used to specify the location of the attachment file.

-i used to specify a file containing the message body.

Sending Mail With Attachment

There are a couple of ways you could send a mail with attachment using mutt, you can either use the text-based interface or use it directly in your shell, I'll show you both ways:

To send mail via the interface, use the following steps:

  1. Type m in your keyboard, and beneath the interface you'll see a "To:" enter the address you which to send email to
  2. Enter Subject, hit Enter and you'll be taken to your editor, this is where you would compose the message. Compose your message and save
  3. Now, you'll see 'Attach file ('?' for list): enter ?, and attach file in that directory. You can also change the directory where the file is located by typing c, once you are done...
  4. Type y to send

To send a mail with attachment via the command line, you do the following:

mutt -s "subject" recipient@example.com -a attachment.txt

-a is used to used to specify attachment file. If you don't place -a end of the option, it won't work.

Related Post(s)

  • Setting Up Send-Only Mail Server From Scratch (With Haraka)

    In this guide, I would walk you through the steps of setting up an email server that can be used as a send-only mail server, we would not be dealing with receiving mails, we only care about sending em

  • Using Pageant To Automatically Authenticate SSH key in Putty

    I can't count how many times I have typed my ssh key passphrase whenever my ssh connection times out, it is so annoying and repetitive. Well, thanks to the putty pageant, you can do that seamlessly.

  • Installing WP-CLI In a GNU/Linux Server

    WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPr

  • How To Send Mail To Multiple Addresses Using (mailx)

    In this guide, you'll learn a couple of ways you can send mail to multiple addresses using mailx. mailx is a utility program for sending and receiving mail. I assume you already have mailx command, i

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll

  • Test Your Internet Download Speed from Terminal Using (Fast)

    Fast is a tiny utility program for testing your internet download speed from the terminal, to get started, you simply install via the snap store (Ubuntu): sudo snap install fast If you don't have sna