• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

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. Understanding Failover in a Pacemaker Cluster
  2. Why Does “netstat” Output Show Many Connections in CLOSE_WAIT Status?
  3. CentOS / RHEL 6 : How to configure kdump
  4. How to use FTP under Linux to transfer files
  5. Linux OS Service ‘setroubleshoot’
  6. CentOS / RHEL : Begginners guide to cron
  7. How to transfer files securely using sftp (examples included)
  8. CentOS / RHEL : How to find which user run a specific command?
  9. How to automate sftp file transfers using expect utility
  10. The ultimate Linux interview questions : swap

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable firewalld and nftables and use iptables instead in CentOS/RHEL 8
  • How to add an Ethernet connection using nmcli in CentOS/RHEL 7
  • How to set the order to load certain modules in CentOS/RHEL 7 and 8
  • How to configure initrd / initramfs to including kernel modules in CentOS/RHEL
  • How to configure systemd.path to trigger an event when any changes made to a directory
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary