msmtp

    See also other alternatives

    Configuration

    /etc/msmtprc:

    # Generics
    defaults
    auth           on
    tls            on
    # following is different from ssmtp:
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    # user specific log location, otherwise use /var/log/msmtp.log, however,
    # this will create an access violation if you are user pi, and have not changes the access rights
    logfile        /var/log/.msmtp.log
    
    # Gmail specifics
    account        gmail
    host           smtp.gmail.com
    port           587
    
    from          root@raspi-buster
    user           your-gmail-accountname@gmail.com
    password       your-gmail-account-password
    
    # Default
    account default : gmail
    

    Send an email

    ### cli

    echo 'your message' | msmtp email@domain.tld
    

    file

    mail.txt

    To:username@example.com
    From:youraccount@gmail.com
    Subject: Test
    
    This is a test mail.
    
    msmtp -t < mail.txt