Thursday, December 13, 2012

Changing FreePBX postfix SMTP server (to Gmail)

FreePBX uses the "postfix" package by default to send emails. This usually works for most people, but since the emails are just being sent directly from the FreePBX machine and not a standard mail server, it is most likely to get flagged as spam.

To lower the chance of messages getting flagged as spam, I setup a Gmail account and used its SMTP servers to send email.

FreePBX Version

I have performed these steps on the FreePBX 1.814 and an earlier distribution. If you're using postfix for email, then these instructions should work for you.

  • A gmail account created at
  • Knowledge of using SSH command line
  1. Add the following lines to /etc/postfix/ file:
    relayhost = []:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    smtp_use_tls = yes

  2. Create the file /etc/postfix/sasl_passwd with the following contents:
    []:587 [email protected]:password

  3. Restrict permissions on the postfix file:
    chmod 400 /etc/postfix/sasl_passwd

  4. Hash the file into a .db that Postfix will read:
    postmap /etc/postfix/sasl_passwd

  5. Change the owner of the sasl_passwd to the postfix user:
    chown postfix /etc/postfix/sasl_passwd

  6. Reload postfix:
    /etc/init.d/postfix reload


  1. Great post. Worked well for me. I did this on a FreePBX 2.10

    Thank you

  2. I tried this but in the mail log /var/log/maillog I'm getting 554 5.7.1 : Sender address rejected.

    I did not get any errors when I put in all the commands from above. The only thing I did differently was use the instead of google. I verified that 587 is still the port. Any ideas?

  3. Just tested it and works, thanks you very much

  4. One the few times I actually used something from the Internet and it worked the first time!!!

    It appears that there is a weakness and too much complexity in FreePBX when it comes to simply sending out emails with Voice Mail Attachments.

    Thank you again for filling in a large gap...

  5. Replies
    1. Strangely enough I've tried this on a Zoho account and a Google Apps account and it doesn't work, but it does on my plain vanilla gmail account. I have no idea why that should be?

  6. This worked like a champ the first time around with FreePBX/Asterisk 11 with Centos 6.

  7. I almost forgot, I thank you very much.

  8. This comment has been removed by a blog administrator.

  9. This comment has been removed by a blog administrator.

  10. This comment has been removed by a blog administrator.

  11. This comment has been removed by a blog administrator.

  12. This comment has been removed by a blog administrator.

  13. This comment has been removed by a blog administrator.

  14. This comment has been removed by a blog administrator.

  15. Work very nice with RasPBX (Raspberry pi)
    - Asterisk 13.20.0
    - FreePBX

  16. This comment has been removed by a blog administrator.

  17. When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. 2013 Aged/Old Gmail

  18. I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting about freepbx.
    Tangki Panel

  19. This worked for me in 2020. Thank you for posting.
    Asterisk 16.6.2

  20. Extremely helpful post. This is my first time visiting here. I discovered such a large number of intriguing stuff in your blog particularly its exchange. Truly its extraordinary article. Keep it up. FreePBX Exploit Phone Home

  21. This is truly satisfactory to examine the substance of this blog. An is incredibly wide and epic capable stage has been known by this blog. I really welcome this blog to have such kind of enlightening data. Cloud PBX Charlotte

  22. Keep it up and in the future sharing more articles like this. I read your post and got it quite informative. I couldn't find any knowledge on this matter prior to. You are sharing a piece of nice information, it helped me. If anyone looking for the Email Finder Free then visit our website at

  23. Thanks for giving me your time to share this article here. Your article is very educational and I am affected by the details that you have shared in this post. Thanks for the wonderful article. pbx system for small business

  24. Your article contains very much information about the server. Your article is very informative and useful to know more about the streaming. Thank you for sharing this article here. Oracle Fusion Manufacturing online Training

  25. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work. asterisk pbx

  26. Wow, What an Excellent post.I really found this to much informative. It is what I was searching for.I would like to suggest you that please keep sharing such type of info. email validation services

  27. Gmail got some truly incredible highlights and one should know everything to appreciate Gmail at its best. I will attempt my level best to clarify however much I can about Gmail from my own insight and expectation that this article will may assist you with utilizing Gmail all the more effectively. buy instagram accounts

  28. Nice post. I'm impressed by this blog. There is so much information about this topic. Thanks for sharing an amazing article like this. please keep posting. Mailing Companies Scottsdale

  29. Quite an amazing post which you have shared here postfix SMTP server. It is a genuinely informative and helpful post. Much obliged to you for sharing it. Email Marketing Services For Small Business

  30. This is important information which is shared by you. This info is meaningful and important for everyone to increase our knowledge about it. Always keep sharing this kind of information. Thank you. buy old gmail accounts in bulk for business