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.


  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
    port 587
    protocol smtp
    auth on
    password YOUR_PASSWORD
    tls on
    tls_starttls on
    tls_certcheck off

  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

  5. Test sending email from FreePBX

Return to Documentation Home I Return to Sangoma Support