Configuring MSMTP with gmail as a mail transfer agent

 

This is an easy-to-setup alternative to postfix or sendmail configuration. The instructions have been written for Debian but should be easy to adjust for other Linux distributions.

Instructions

  1. Log in as root and issue the following command:
    apt install msmtp-mta bsd-mailx

  2. Create the file .msmtprc inside home of asterisk user
    cat <<HERE > ~asterisk/.msmtprc
    account default
    host smtp.gmail.com
    port 587
    protocol smtp
    auth on
    from YOUR_GMAIL_ACCOUNT@gmail.com
    user YOUR_GMAIL_ACCOUNT@gmail.com
    password YOUR_PASSWORD
    tls on
    tls_starttls on
    tls_certcheck off
    HERE

  3. Set correct permissions
    chown asterisk:asterisk ~asterisk/.msmtprc
    chmod 600 ~asterisk/.msmtprc

  4. Send a test email from CLI (under asterisk user)
    echo "test email" | mail -s test_email OTHER_EMAIL@SOME_PROVIDER.com

  5. Test sending email from FreePBX

Return to Documentation Home I Return to Sangoma Support