• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How To Setup mutt in CentOS/RHEL

by admin

Mutt is a full-featured text-based Mail User Agent that supports the typical mail formats and protocols while providing comprehensive support for MIME, GPG, and PGP. By its very nature Mutt is a very useful package, and because it is a tool that all server administrators should become familiar with, it is the purpose of this recipe to show you how Mutt can be used to deliver customized reports and messages to a destination of your choice.

Installing and Configuring mutt

1. Install the mutt RPM package if needed.

# yum install -y mutt

2. Review the online documentation:

# man mutt

3. Set your mail distribution server in the system-wide configuration file. Take a backup of the configuration file before making any changes.

# cp -p /etc/Muttrc /etc/Muttrc.ORIG
# vi /etc/Muttrc

### Change the mail handler to have a line reading:
smtp_url=smtp://mailserver.thegeekdiary.com

4. Save the file. restart any mutt sessions already active.

Sending e-mail Using mutt Command

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

Here
-s is used to specify subject of mail.
-i is used to specify file containing message body.
-a is used to specify attachment file.

Some other commonly used options with mutt are:
-b is used to add Bcc address.
-c is used to add Cc address.
-e “unmy_hdr from; my_hdr From: test@test.com” – if you want to specify sender’s address (something other than default).

Mutt can also be used in interactive mode. To start it just type “mutt” on command line.

# mutt

How to Send an eMail in HTML Format Using mutt?

Use the below syntax to use mutt to send HTML mail:

# mutt -e "set content_type=text/html" [user@domain.com] -s "This is the subject" < /tmp/email_body.html

where,
/tmp/email_body.html has the html mail body.

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. scp Command Examples in Linux
  2. btrfs filesystem Command Examples in Linux
  3. md5sum: command not found
  4. How to clean YUM cache in CentOS / RHEL
  5. lolcat Command Examples in Linux
  6. add-apt-repository: command not found
  7. What are “segfault” messages in /var/log/messages file
  8. smbclient: command not found
  9. tomb: command not found
  10. “Server refused to allocate pty” – Unable to login to CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright