Ubuntu 14.04 + Mutt + Msmtp configure the command line mail client in Linux

Source: Internet
Author: User

Ubuntu 14.04 + Mutt + Msmtp configure the command line mail client in Linux

Install msmtp mutt in Ubuntu 14.04

Apt-get install-y msmtp mutt

Configure msmtp
After the installation is complete, configure msmtp first. The default configuration file varies with the operating system version and can be viewed through msmtp -- version.

# Msmtp -- version
Msmtp version 1.4.31
Platform: x86_64-pc-linux-gnu
TLS/SSL library: GnuTLS
Authentication library: GNU SASL
Supported authentication methods:
Plain scram-sha-1 cram-md5 gssapi external digest-md5 login ntlm
IDN support: enabled
NLS: enabled, LOCALEDIR is/usr/share/locale
Keyring support: none
System configuration file name:/etc/msmtprc
User configuration file name:/root/. msmtprc

Copyright (C) 2013 Martin Lambers and others.
This is free software. You may redistribute copies of it under the terms
The GNU General Public licensing There is no warranty, to the extent permitted by law.
Here we use/etc/msmtprc to set the global configuration of the machine, regardless of the original configuration file, replace it with the following configuration file

# Set default values for all following accounts.
Ults
# The SMTP server of the provider.
Account default
Host smtp.163.com
From xxx@163.com
Auth login
User xxx@163.com
Password xxxpassowrd
Tls off
Syslog on
Msmtp is configured here. For more detailed configuration, you can use man msmtp for help. Finally, there are configuration examples.

Configure mutt
There are also two mutt configuration files.

~ /. Muttrc or ~ /. Mutt/muttrc
User configuration file.

/Etc/Muttrc
System-wide configuration file.
Similarly, we use global configuration.

Set sendmail = "/usr/bin/msmtp" # path of your msmtp command
Set use_from = yes
Set realname = "xxx@163.com" # Here is your sender alias, can be not the mail address
Set editor = "vim"
Test email sending
Df-h | mutt-s "useage of hd" xxx@163.com
Use the client to receive the following email content:

Useage of hd
Xxx@163.com
Sent to xxx
For more information, see
Filesystem Size Used Avail Use % Mounted on
/Dev/mapper/ubuntu -- vg-root 95G 2.1G 88G 3%/
None 4.0 K 0 4.0 K 0%/sys/fs/cgroup
Udev 3.9G 4.0 K 3.9G 1%/dev
Tmpfs 799 M 552 K 798 M 1%/run
None 5.0 M 0 5.0 M 0%/run/lock
None 3.9G 0 3.9G 0%/run/shm
None 100 M 0 100 M 0%/run/user
/Dev/sda1 236 M 37 M 187 M 17%/boot
Configure the nagios alarm email to be sent using mutt. Replace the mail command with mutt in nagios command. cfg.

# 'Policy-host-by-email 'command definition
Define command {
Command_name sort y-host-by-email
Command_line/usr/bin/printf "% B" "****** Nagios ***** \ n \ nNotification Type: $ icationicationtype $ \ nHost: $ HOSTNAME $ \ nState: $ HOSTSTATE $ \ nAddress: $ HOSTADDRESS $ \ nInfo: $ HOSTOUTPUT $ \ n \ nDate/Time: $ LONGDATETIME $ \ n "|/usr/bin/mutt-s" ** $ icationicationtype $ Host Alert: $ HOSTNAME $ is $ HOSTSTATE $ ** "$ CONTACTEMAIL $
}

# 'Your y-service-by-email 'command definition
Define command {
Command_name sort y-service-by-email
Command_line/usr/bin/printf "% B" "****** Nagios ***** \ n \ nNotification Type: $ icationicationtype $ \ n \ nService: $ SERVICEDESC $ \ nHost: $ HOSTALIAS $ \ nAddress: $ HOSTADDRESS $ \ nState: $ SERVICESTATE $ \ n \ nDate/Time: $ LONGDATETIME $ \ n \ nAdditional Info: \ n $ SERVICEOUTPUT $ \ n "|/usr/bin/mutt-s" ** $ icationicationtype $ Service Alert: $ HOSTALIAS $/$ SERVICEDESC $ is $ SERVICESTATE $ ** "$ CONTACTEMAIL $
}

Mutt -- an Email client that sends emails through a terminal

Install and configure m1_tp and mutt

Send an email via mutt to 139 mailbox for text message

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.