Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    SMTP notifications not working with gmail

    Scheduled Pinned Locked Moved General pfSense Questions
    12 Posts 6 Posters 4.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      OpensourceProtection
      last edited by

      So I've been trying for around 2-3 hours now to get SMTP notifications to work on PFSense 2.4.2.

      The end goal is to get it sending the notifications to a G-suite account with 2-factor turned on. However, when that didn't work for testing purposes I utilized my personal accounts and received the exact same error. I've tried https://forum.pfsense.org/index.php?topic=125528.msg779514#msg779514 and that, unfortunately, didn't help.

      I've tried G-suite with 2-factor app password, personal account with 2 factor with app password, and personal without 2 factor with allow less secure turned on.  All of them received the exact same error code below

      Could not send the message to ABCDE@gmail.com – Error: Failed to connect to ssl://smtp.gmail.com:587 [SMTP: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.gmail.com:587 (Unknown error) (code: -1, response: )]

      The setting I've tried are,

      E-Mail server: smtp.gmail.com (as well as looking up the IP with nslookup and hard coding, no change.)
      SMTP Port of E-Mail server: Tried both 465 and 587
      Connection timeout: both 20 and 60
      Secure SMTP Connection: I leave it checked.
      From e-mail address: valid email account 1
      Notification E-Mail address: valid email account 2
      Notification E-Mail auth username(optional): valid email account 1
      Notification E-Mail auth password: Both app password and real password
      Notification E-Mail auth mechanism: Both Login and Plain

      Any help would be greatly appreciated, thanks so much in advance!

      SOLVED!!!

      Every time you test the connection you have a to reinput the password (and possibly other fields). Even though you'll see the shortened black dots, the password is not saved from the test before. (I'm assuming it's reverting to what it has saved but can't say for certain.)  I was seeing the shortened black dots and thought PFSense was rolling over the password from the previous try this was not the case.  When I followed a guide it worked like a charm the first time, and when tested again it failed like before. That's what clued me in.

      If I entered everything fresh, hit save, THEN hit test I could get it working multiple times in a row.

      1 Reply Last reply Reply Quote 1
      • S
        slim2016
        last edited by

        Have a read of this http://strongitguy.com/setting-up-custom-app-passwords-in-gmail-for-smtp-email-notifications-in-pfsense/

        1 Reply Last reply Reply Quote 0
        • O
          OpensourceProtection
          last edited by

          Thanks for speedy reply slim2016, unfortunately, I tried the guide and still receive the same error code as posted above. The only difference is that the ending port number is 465 instead of 587.

          1 Reply Last reply Reply Quote 0
          • S
            slim2016
            last edited by

            I was using a different email for my notification  but i thought I give this gmail a go and it worked at first try. I did however copy and pasted the password on a text file first just to make sure there wasn't any spaces. Maybe someone with more experience can help you.

            1 Reply Last reply Reply Quote 0
            • O
              OpensourceProtection
              last edited by

              I wouldn't call this solved, more of a temporary workaround until it's solved.  I got it to where I can get the emails utilizing an internal SMTP relay server, that then forwards said emails onwards.

              1 Reply Last reply Reply Quote 0
              • johnpozJ
                johnpoz LAYER 8 Global Moderator
                last edited by

                I have been using pfsense and gmail in the notification for like ever.. Never had any issues.  Below is my setup..

                I blacked out the gmail address using… And the password is a app password setup in gmail.

                gmailnotification.png
                gmailnotification.png_thumb

                An intelligent man is sometimes forced to be drunk to spend time with his fools
                If you get confused: Listen to the Music Play
                Please don't Chat/PM me for help, unless mod related
                SG-4860 24.11 | Lab VMs 2.7.2, 24.11

                1 Reply Last reply Reply Quote 0
                • GrimsonG
                  Grimson Banned
                  last edited by

                  @OpensourceProtection:

                  SMTP Port of E-Mail server: Tried both 465 and 587
                  Secure SMTP Connection: I leave it checked.

                  Set the port to 587 and uncheck "Secure SMTP Connection" it will then use StartTLS.

                  1 Reply Last reply Reply Quote 0
                  • johnpozJ
                    johnpoz LAYER 8 Global Moderator
                    last edited by

                    Yup that works too… Just changed settings and still works...

                    edit:  Here is the exchange of sending test message.. Which is what I would suggest you do.. So you can actually see what the problem is..

                    othersettings.png
                    othersettings.png_thumb
                    exchangegamailsniff.png_thumb
                    exchangegamailsniff.png

                    An intelligent man is sometimes forced to be drunk to spend time with his fools
                    If you get confused: Listen to the Music Play
                    Please don't Chat/PM me for help, unless mod related
                    SG-4860 24.11 | Lab VMs 2.7.2, 24.11

                    1 Reply Last reply Reply Quote 0
                    • O
                      OpensourceProtection
                      last edited by

                      Solved!

                      Every time you test the connection you have a to reinput the password. Even though you'll see the shortened black dots, the password is not saved from the test before. (I'm assuming it's reverting to what it has saved but can't say for certain.)  I was seeing the shortened black dots and thought PFSense was rolling over the password from the previous try this was not the case. Once I copied the setting of johnpoz (with the appropriately changed email addresses) it worked like a charm the first time, and when tested again it failed like before. That's what clued me in.

                      If I entered everything fresh, hit save, THEN hit test I could get it working multiple times in a row.

                      Thank you everyone for your help with this!

                      C 1 Reply Last reply Reply Quote 1
                      • johnpozJ
                        johnpoz LAYER 8 Global Moderator
                        last edited by

                        Glad you got it working… But it clearly states on the form that "The last SAVED values will be used, not necessarily the values entered here." ;)

                        saved.png
                        saved.png_thumb

                        An intelligent man is sometimes forced to be drunk to spend time with his fools
                        If you get confused: Listen to the Music Play
                        Please don't Chat/PM me for help, unless mod related
                        SG-4860 24.11 | Lab VMs 2.7.2, 24.11

                        D 1 Reply Last reply Reply Quote 0
                        • D
                          discy @johnpoz
                          last edited by discy

                          Had the same issue. Password wasn't saved and would be gone when I re-opened the interface.
                          Test wouldn't work after re-opening the interface, while it worked after I saved.

                          • Disabled/Enabled SMTP over SSL
                          • Changed port
                          • Hit save a couple of times in between.

                          Now the password is kept saved, back on SSL and port 465.
                          Test also works after reloading the interface.

                          Definitely something funky going on here.

                          1 Reply Last reply Reply Quote 0
                          • C
                            CrowFather @OpensourceProtection
                            last edited by

                            @opensourceprotection said in SMTP notifications not working with gmail:

                            Solved!

                            Every time you test the connection you have a to reinput the password. Even though you'll see the shortened black dots, the password is not saved from the test before. (I'm assuming it's reverting to what it has saved but can't say for certain.)  I was seeing the shortened black dots and thought PFSense was rolling over the password from the previous try this was not the case. Once I copied the setting of johnpoz (with the appropriately changed email addresses) it worked like a charm the first time, and when tested again it failed like before. That's what clued me in.

                            If I entered everything fresh, hit save, THEN hit test I could get it working multiple times in a row.

                            Thank you everyone for your help with this!

                            This was the solution to the issue I was having! Thanks for your help.

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.