• Issue
  • connection error setting up gmail smtp

I’m really struggling with setting up our freeflaurm account https://wmbanjonet.flarum.cloud/ to use smtp with gmail for sending out notifications. Hoping someone can spot what I’m doing wrong! I’ve been using just the mail driver up until now, but notifications are going to users’ spam folders, so any possible discussions keep “dying on the vine.”

I’ve read through many support discussions and have tried various recommendations. But whenever I try sending a test email, about a half minute goes by then I get the “Oops Something went wrong” message and a “connection could not be established” error in our logs.

Two examples of settings and errors are below. In each case, I’m using the app password generated by gmail. After creating the app password, I checked gmail’s security notifications and confirmed that it was me that created the password. I then copied and pasted the app password into the flarum email settings along with the other settings shown below. (I also removed the spaces because gmail presents it like “abcd efgh ijkl mnop”).

Using port 587 and tls encryption….
Addresses: wmbanjonet@gmail.com
Choose a Driver: smtp
SMTP Settings
Host: smtp.gmail.com
Port: 587
Encryption: tls
Username: wmbanjonet@gmail.com
Error log:
flarum.ERROR: Swift_TransportException: Connection could not be established with host smtp.gmail.com :stream_socket_client(): Unable to connect to tcp://smtp.gmail.com:587 (Connection timed out) in /data/host/skeleton/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:261

Using port 465 and ssl encryption….
Addresses: wmbanjonet@gmail.com
Choose a Driver: smtp
SMTP Settings
Host: smtp.gmail.com
Port: 465
Encryption: ssl
Username: wmbanjonet@gmail.com
Error log:
flarum.ERROR: Swift_TransportException: Connection could not be established with host smtp.gmail.com :stream_socket_client(): Unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) in /data/host/skeleton/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:261

Can you see what I’m doing wrong, or recommend something else to try?
Thanks!

    BobPapp can you try port 25 and leave the encryption field blank to confirm that it’s (not) the encryption acting up?

    Thanks for the quick response!

    Trying that generated the same error:
    [2025-03-20 21:37:44] flarum.ERROR: Swift_TransportException: Connection could not be established with host smtp.gmail.com :stream_socket_client(): Unable to connect to smtp.gmail.com:25 (Connection timed out) in /data/host/skeleton/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:261

    And here are my settings to confirm:

    Good morning! I’m just touching base to see if you had any other thoughts on how to solve this, after the test with port 25 also failed. I’ve been thinking about getting a free mailgun account and trying that but not sure if that would make any difference…. I’d rather stick with using gmail if possible but open to anything to get smtp working.

    Thanks again for any further direction you can provide.

      BobPapp hi, sorry for not getting back to this sooner, I was busy and so I couldn’t look into this further. But from what I see, this seems like an issue on FreeFlarum’s end. I will have a look into it as soon as I get the chance. Meanwhile, you should use FreeFlarum’s default mail settings (mail driver with noreply+forumname@freeflarum.com address)

      Ok, thanks. We’d been using the default mail settings but those notifications kept ending up in spam, even when added to a contact list. That’s why were hoping to get the smtp setting working. Please let me know if/when you find anything. Thanks again for the help!

      Sorry to bug you but I have one more update and a question. I tried using mailgun, but decided I was in over my head so I switched it back to the “mail” driver and tested that to be sure it was working again. The test mail arrived, but it was from the gmail account I set up rather than noreply+wmbanjonet@freeflarum.com. I realized I’d forgotten to change the Addresses field but now I’m wondering, is it ok to leave it like this? It appears it’s using the “mail” driver to route notifications through the gmail server…. Here are my current settings:

        BobPapp it should use the noreply+forumname@freeflarum.com address format

        Right, I know that’s what’s supposed to go in the Addresses field when using the “mail” driver, but the gmail address I accidently left there actually did work with the mail driver selected. The test email arrived from the gmail address. So I’m wondering if it’s ok to leave it like that or if that may cause other unforeseen issues. Like maybe it’s just a fluke that it’s working now but it won’t always?

        Here’s how the email arrived with the settings shown in my last post.

          9 days later

          BobPapp it will show like this for you, for others it will be marked as spam and potentially gets deleted without even seeing the in- or spambox.

          Ok. We have the same problem when using the “Mail” driver (going to spam). That’s why we were trying to get smtp to work with gmail, but to no avail. Skevo thought it might be due to an issue on an FreeFlarum’s end. So it seems we don’t have any working options to avoid the spam filters. I looked into mailgun but got in over my head with the settings so had to give up.