XF 2.2 Activation Emails Not Being Sent

Jessiray

New member
Hello,

I am posting on here because I have just installed Xenforo onto my Ubuntu 18 server. I read that email activation should work out of the box with the PHP mailer, however this was not the case. When using the php mailer, I get an 'email successfully sent' when doing an Outgoing Email Test but the mail never arrives. I figured this might be due to Gmail blocking mail from an untrusted server. So I went through the steps to set up a separate gmail account for the forum to send emails from and the steps to generate the OAuth ID.

Here are my current parameters in the Transfer Method field:
Connection type: SMTP (Google OAuth)
Host: smtp.gmail.com:465
Username: addressofemail@gmail.com
Encryption: SSL

Here is the full dump and stack trace from my server logs:
Here's the more extended log dump and the stacktrace:

Code:
Swift_TransportException: Email to my.email@gmail.com failed: 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) Log data: ++ Starting Swift_SmtpTransport !! 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) (code: 0) src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php:124

#0 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php(139): Swift_Plugins_LoggerPlugin->exceptionThrown()
#1 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php(119): Swift_Events_SimpleEventDispatcher->bubble()
#2 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(432): Swift_Events_SimpleEventDispatcher->dispatchEvent()
#3 src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(145): Swift_Transport_AbstractSmtpTransport->throwException()
#4 src/XF/Mail/Mailer.php(286): Swift_Transport_AbstractSmtpTransport->start()
#5 src/XF/Mail/Mail.php(404): XF\Mail\Mailer->send()
#6 src/XF/Admin/Controller/Tools.php(278): XF\Mail\Mail->send()
#7 src/XF/Mvc/Dispatcher.php(350): XF\Admin\Controller\Tools->actionTestEmail()
#8 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass()
#9 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch()
#10 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop()
#11 src/XF/App.php(2300): XF\Mvc\Dispatcher->run()
#12 src/XF.php(465): XF\App->run()
#13 admin.php(13): XF::runApp()
#14 {main}

Request state
array(4) {
  ["url"] => string(27) "/admin.php?tools/test-email"
  ["referrer"] => string(46) "https://websiteurl.net/admin.php?tools/test-email"
  ["_GET"] => array(1) {
    ["tools/test-email"] => string(0) ""
  }
  ["_POST"] => array(2) {
    ["email"] => string(24) "my.email@gmail.com"
    ["_xfToken"] => string(8) "********"
  }
}

Postfix/SMTP are configured to use gmail. Port 465 is open and I can telnet to it from my normal PC. For those who got the OAuth confirmation working for a gmail account, is there anything else I need to install/edit/configure? I've submitted a ticket to my host to ensure they aren't blocking us either.

Thanks in advance!
 

Mouth

Well-known member
Code:
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)
... being your issue.
Try port 587 with TLS?
 

Jessiray

New member
Code:
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)
... being your issue.
Try port 587 with TLS?
Hi Mouth,
I have port 587 open, but Xenforo defaults to 465 in this setting and I don't see an option to change it. 465 is also open and configured. I can get to it with telnet.

Thank you!
 

Jessiray

New member
Try non-encrypted 587 port. It should work.
Thank you ALMUSA, I looked for this. However, I do not see the option to change the port Xenforo is looking for when I use OAuth. It only asks for my Client ID and Client Secret. I have put those in and they have been accepted, but it's automatically setting the port to 465 and I don't see a manual configuration for it. I appreciate your help though!
 

KSA

Well-known member
Thank you ALMUSA, I looked for this. However, I do not see the option to change the port Xenforo is looking for when I use OAuth. It only asks for my Client ID and Client Secret. I have put those in and they have been accepted, but it's automatically setting the port to 465 and I don't see a manual configuration for it. I appreciate your help though!

The email setup is under option

example.com/admin.php?options/groups/emailOptions/

There you can configure your email setting.
 

Jessiray

New member
I think OAuth pulls all settings automatically. Try STMP and enter your info manually and you use 587 as your port.
Thanks for your suggestions ALMUSA, but I figured out the issue.

I needed to contact Linode and have them allow me to use that port. It was being blocked from sending mail at their level, not mine. Xenforo is sending mail now, with OAuth set up and everything.

Have a good day!
 

Jessiray

New member
I did actually tell you that in your ticket this afternoon.
Yes, you did! It's what prompted me to go on and send the ticket to Linode in addition to the one here. I was worried I was missing something either in the back end of the server that I needed to set up (such as a port setting) or in Xenforo so I figured I'd post here as maybe someone else had the issue as well.

But you were right, it really was as simple as Linode enabling SMTP traffic to the server. Thank you as well for your help.
 
Top