Email Notifications Configuration (SMTP via Postfix)

Good Afternoon Colleagues
I hope you are doing good and safe . I am trying to configure email postfix so i can send email notifications from FreePBX but i am not successful so far. i am using my Gmail account. Below is the details of my system:

  • Free PBX Version: 15.0.17.48
  • PBX Distro: 12.7.8-2104-1.sng7
  • Asterisk Version: 16.17.0

Let me share with you the steps i did so far:

Below is the configuration at /etc/postfix/main.cf

relayhost = smtp.gmail.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_generic_maps = hash:/etc/postfix/generic

I create file “sasl_passwd” under /etc/postfix . Below is configuration of this file:

smtp.gmail.com:587 [email protected]:mypassword

Then i modify /etc/postfix/generic as below:

root [email protected]
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected]
asterisk [email protected]
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected]
@freepbx.localdomain @gmail.com

After that i do the following:

  • Set permissions ‘chmod 400 /etc/postfix/sasl_passwd’
  • Run ‘postmap hash:/etc/postfix/sasl_passwd’
  • Change owner ‘chown postfix /etc/postfix/sasl_passwd’

then issue command " postmap /etc/postfix/generic"

then reload postfix: “service postfix restart”

I can’t send email neither from Linux CLI nor from FreePBX so any suggestion how can i make this work ?

Thanks in advance.

Best Regards

Normally in my sasl_passwd file I put

relayhost [email protected]

Please post your /var/log/maillog in pastebin so we can see.

Did you hash the file?

This should be:

@freepbx.localdomain [email protected]

Also, you may have to enable less secure apps login on that gmail account. But Google will soon stop allowing that: Less secure apps & your Google Account - Google Account Help

Hi adell4444
I add this line “relayhost [email protected]” to sasl_passwd file but same result.

Below the link of pastebin for maillog
https://pastebin.freepbx.org/view/035a87d6

Thanks in advance.

Best Regards

Hi PitzKey

  • May i know how can i hash the file?
  • I will try to use another domain and will let you know.

Best Regards

SASL authentication failed; server [smtp.gmail.com](http://smtp.gmail.com/)[142.250.110.109] said: 534-5.7.9 Application-specific password required. Learn more at?534 5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor n20-20020a05600c501400b0038995ede299sm2164546wmr.17 - gsmtp)

@PitzKey made a suggestion about allowing less-secure passwords.

postmap hash:/etc/postfix/sasl_passwd

Hello @adell4444 & @PitzKey
I have used another domain rather that Gmail . Below is server settings:

I tried both secure settings & non-secure settings but nothing work . When using non-secure settings , I disable this line “#smtp_use_tls = yes”. I changed also settings in “sasl_passwd” file accordingly.

@PitzKey I issue the command “postmap hash:/etc/postfix/sasl_passwd”

Below is the logs after using the secure & non-secure settings

https://pastebin.freepbx.org/view/1bb320a6

Thanks in advance and waiting for your support.

Best Regards

Mar 6 04:19:03 freepbx postfix/smtp[15869]: 1C3AA603CEFF3: to=<[email protected]>, relay=mail.siscomgroup.ca[162.241.219.155]:25, delay=75973, delays=75966/0.01/6.9/0.08, dsn=4.5.2, status=deferred (host mail.siscomgroup.ca[162.241.219.155] said: 452 4.5.2 Could not resolve sender domain. (in reply to MAIL FROM command))

Seems like you have DNS issues.

Anyway, why disable TLS?

Good Afternoon Colleagues
I would like to share with you that things has worked as expected . I disabled TLS because when using TLS , Our main server using port 465 not 587 . Thanks @PitzKey & @adell4444 for your support and have a nice day ahead.

Below is the the final configuration for main.cf that worked with my email server (Similar to GoDaddy) .

relayhost = [mail.siscomgroup.ca]:25
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_generic_maps = hash:/etc/postfix/generic

Best Regards

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.