msmtp - light SMTP client with support for server profiles
msmtp is an SMTP client that can be used to send mails from MUAs (mail user agents) like Mutt or Emacs. It forwards mails to an SMTP server (for example at a free mail provider), which takes care of the final delivery. Using profiles, it can be easily configured to use different SMTP servers with different configurations, which makes it ideal for mobile clients.
Installation
config example
You need to put your settings in ~/.msmtprc.
An example is provided in /usr/share/doc/msmtp/examples/msmtprc-user.example.
To send email via a Gmail account:
# Set default values for all following accounts. defaults port 587 tls on tls_trust_file /etc/ssl/certs/ca-certificates.crt logfile ~/.msmtp.log account gmail host smtp.gmail.com from <user>@gmail.com auth on user <user>@gmail.com passwordeval gpg --no-tty --quiet --decrypt ~/.msmtp-gmail.gpg # Set a default account account default : gmail
Others examples with debian.org and zoho + your domain:
# Set default values for all following accounts. defaults tls on auth on tls_trust_file /etc/ssl/certs/ca-certificates.crt logfile ~/.msmtp.log account zoho port 465 host smtp.zoho.com tls_starttls off from <user>@your-domain.com user <user>@your-domain.com passwordeval gpg --no-tty --quiet --decrypt ~/.msmtp-zoho.gpg account debian host mail-submit.debian.org port 587 tls_starttls on from <user>@debian.org user <user> passwordeval gpg --no-tty --quiet --decrypt ~/.msmtp-debian.gpg # Set a default account # account default : debian account default : zoho
Then store your credentials in a Secret Service compatible program such as keepassxc, gnome-keyring, kwalletmanager.
Otherwise, the credentials can be stored in an OpenPGP-encrypted password file, which can be created like this:
$ gpg --encrypt --output=.msmtp-gmail.gpg --recipient=<user>@gmail.com - <<END ThisIsMySeCrEtPassword END $ gpg --encrypt --output=.msmtp-zoho.gpg --recipient=<<user>@your-domain.com - <<END ThisIsMySeCrEtPassword END $ gpg --encrypt --output=.msmtp-debian.gpg --recipient=<user>@debian.org - <<END ThisIsMySeCrEtPassword END
Make sure you don't forget the dash near the end, which causes gpg to use "standard input" to read the password of your private OpenPGP key. After you have launched this command, it waits for your password. Type your password, hit Enter and finish with Control-d. Then, gpg encrypts your password, stores the result into the file and terminates.
To test it, run:
$ printf "To: _recipient_address_\n\nSubject: Test\n\nHello, This is my test message." | msmtp -a default _recipient_address_
gpg-agent will prompt you for your OpenPGP key passphrase when sending email.
Then you should find your sent e-mail in the _recipient_address_'s inbox shortly afterwards.
msmtp-mta
When a standard MTA interface is desired, but a full server like Postfix or Exim is not desired, then the msmtp-mta package can be a solution:
Install the msmtp-mta package.
The package provides a /usr/sbin/sendmail symlink to msmtp that other software can use to send mail. The msmtp-mta package also provides a msmtpd daemon that listens on 127.0.0.1:25. This is disabled by default. Keep in mind that the daemon has no way to know which user is connecting to it, so it has to way to use the user's .msmtprc. The system-wide /etc/msmtprc will still apply.
The MTA setup can be tested using with the mail program (provided by a package such as mailutils or bsd-mailx):
$ mail -s "teste" address@email.com <<END This is a test END
If the above does not work, please report it through a bugreport. Try appending this line to /etc/mail.rc:
set mta=/usr/bin/msmtp
Or try switching to a different package for the mail program.
Similar software
External links
CategoryNetwork CategoryMail CategorySoftware CategorySystemAdministration