Use Mutt and msmtp to send Gmail messages under Ubuntu on the command line

Source: Internet
Author: User
Tags message queue gmail mail

Write an email from Ubuntu at the command line

Reference:
Http://www.habadog.com/2011/11/23/send-mail-with-msmtp-mutt-linux
Http://www.absolutelytech.com/2010/07/17/howto-configure-msmtp-to-work-with-gmail-on-linux
MSMTP is a dedicated client software for mail delivery, based on the GPL, support TLS/SSL, DNS mode, IPV6, server-side authentication, multi-user and other features.
Its homepage is msmtp.sourceforge.net:
MSMTP is an SMTP client with a SendMail compatible interface ...
installation
sudo apt-get install mutt MSMTP

If you need support for TLS/SSL, you also need to install GNUTLS or OpenSSL, the official recommended GnuTLS (Https://help.ubuntu.com/community/GnuTLS):
sudo apt-get install Gnutls-bin

Also, use Gmail to install Ca-certificates:
sudo apt-get install ca-certificates
The MSMTP has 3 working modes:
Sendmail Mode (default)
Server Information Mode
Remote Message Queue Starting mode
For sending a message, use Sendmail mode (default) to:
In the default sendmail mode, Msmtp reads a mail from standard input and sends it to an SMTP server for delivery.

Configure MSMTP
When you are finished installing, edit the MSMTP configuration file ~/.MSMTPRC

    Defaults    TLS on    tls_starttls in    tls_trust_file/etc/ssl/certs/ca-certificates.crt account     Default     host smtp.gmail.com    Port 587    auth on    user [email protected]    password mypass from    [email Protected]    logfile ~/msmtp.log

Replace [email protected] and mypass with the actual mailbox and password, where the password is clear text. Note that the sending message defaults to port 25, but the Gmail Mail service is not a 25 port, but a 465 or 587 port. If you do not set the port, sending the message will error "must issue a STARTTLS command first". LogFile If you set the time to pay attention to set access rights, to ensure that the current user writable.

After saving, modify access permissions
chmod 0600. MSMTPRC
If this is not the case, the error will be:
Must has no more than user Read/write permissions

Test Send message:
MSMTP [email protected]
Enter any character, and then press Ctrl+d to exit to see if the message was received. You can view the send log records inside the logfile.
Configure Mutt
View MSMTP Installation path
$ which MSMTP
/usr/bin/msmtp
Edit Mutt configuration file ~/.muttrc

    Set sendmail= "/path/to/msmtp"    set Use_from=yes    set realname= "Your Name"    set [email protected]    set Envelope_from=yes    Set editor= "Vim"

After you can write the message with Mutt through MSMTP sent.

Summary

For a detailed introduction to MSMTP, you can refer to http://msmtp.sourceforge.net/documentation.html or man msmtp.
A sample configuration is provided in the documentation, including the configuration of the Msmtp mate Mutt.

Use Mutt and msmtp to send Gmail messages under Ubuntu on the command line

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.