Write an email from Ubuntu at the command line
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 ...
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.
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.
View MSMTP Installation path
$ which 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.
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