SMTP notifications not working with gmail



  • 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.





  • 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.



  • 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.



  • 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.


  • LAYER 8 Global Moderator

    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.



  • Banned

    @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.


  • LAYER 8 Global Moderator

    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..






  • 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!


  • LAYER 8 Global Moderator

    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." ;)




  • 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.


Log in to reply