Mutt is a popular email client (MUA) which is common on Linux systems.
Given below are some how-tos on basic uses of mutt. For all UNIX utilities, the "man pages" are your best bet to learn them. I’ve just documented some popular uses of mutt. Refer the "man pages" for a more comprehensive understanding of mutt. The commands below have been tested on Red Hat Enterprise Linux 4.0 AS Update 7 with mutt v1.4.1i, unless otherwise stated.
HOW-TO 1: Send email with blank/empty body
mutt -s "Test email" firstname.lastname@example.org < /dev/null # # where: # -s => Subject # email@example.com => recipient's email address #
HOW-TO 2: Send email with body read from a file
mutt -s "Test email" firstname.lastname@example.org < email_body.txt # # where: # -s => Subject # email@example.com => recipient's email address # email_body.txt => file containing message body #
HOW-TO 3: Send email with a customized sender name and email address
# The .muttrc file is Mutt's configuration file. It's default location is the $HOME directory. # If you locate it elsewhere, specify its location with the '-F' flag. # Add the following to the .muttrc file: set realname="Joe Bloggs" set from="firstname.lastname@example.org" set use_from=yes # # where: # realname => Sender's name as it appears in the recipient's mail inbox. # from => the "reply-to" address #
After configuring .muttrc, send emails as per how-tos 1 and 2.
HOW-TO 4: Send attachment(s)
mutt -s "Test email" -a file1 -a file2 email@example.com < /dev/null # # where: # -s => Subject # firstname.lastname@example.org => recipient's email address # file1 => first attachment # file2 => second attachment #
HOW-TO 5: Send HTML email
I know that the technical purists out there abhor HTML emails due to potential issues with accessibility and security, but hey, there’s no denying the fact that HTML-formatted emails are far more interesting to look at than plain-text email and are better at drawing your attention to specific information (ask the marketing guys and senior executives!). HTML-formatted emails are supported by Mutt versions 1.5 and higher. Here’s how you may send an HTML-formatted email using mutt v1.5.21:
mutt -e "set content_type=text/html" -s "Test email" email@example.com < welcome.html # # where: # -s => Subject # firstname.lastname@example.org => recipient's email address # -e => command to execute # content_type => email body MIME type #
The MIME type multipart/alternative ensures your emails are received properly by both plain-text and HTML clients, but it does not work well with mutt at present.