HOWTO Secure the msmtp configuration file using libsecret's secret-tool password manager store and switch from Google to Microsoft SMTP servers (Ubuntu)

Links

Permanent location of video version: https://youtu.be/vHmnH6IijJM

Permanent location of text version: https://www.alanbonnici.com/2020/11/howto-secure-msmtp-configuration-file.html


Introduction and catchup

This is an evolution of "HOWTO Send an email using Gmail from a system configuration using msmtp and heirloom-mailx (Ubuntu)" that you can find at https://www.alanbonnici.com/2020/11/howto-send-email-from-google-from.html 


Libsecret's secret-tool utility

The password manager package that is being used here is called secret-tool and is part of the libsecret tools package. Documentation on this tool is available from http://manpages.ubuntu.com/manpages/focal/man1/secret-tool.1.html.


To save a password:

    secret-tool store  -- label=msmtp host smtp.gmail.com

(when prompted type in the password you want to store)


To verify that the password has been entered correctly:

    secret-tool lookup host smtp.gmail.com


Modify the /etc/msmtprc config file:

    sudo nano /etc/msmtprc

replace password line with 

    passwordeval "secret-tool lookup host smtp.gmail.com"



To use Microsoft rather than Google SMTP

Check the Sync option in your outlook client for the SMTP settings. The port and server name are retrieved from here.


An app password needs to be generated from within Microsoft and stored in the secret-tool vault.


/etc/msmtprc needs to be modified to cater for Microsoft's SMTP server.


    account default

    auth on

    tls on

    tls_trust_file /etc/ssl/certs/ca-certificates.crt

    logfile /var/log/msmtp


    # outlook

    host smtp.office365.com

    port 587

    from <account>@outlook.com

    user <account>

    password "secret-tool lookup host smtp.office365.com"


    # Syslog logging with facility LOG_MAIL instead of the default LOG_USER

    syslog LOG_MAIL


To test from the terminal that the email is working type the following

    echo "Hello, World! (Outlook)" | mail -s "HOWTO #2a" <recipient account>




Comments

Popular posts from this blog

HOWTO setup OpenVPN server and client configuration files using EasyRSA

Boot problems in Microsoft Windows 10 and the way forward.

Understanding PowerShell’s Execution_Policy and Scope functionality - Part 1