4

I have a vanilla Joomla installation. I installed RSForm plugin to send emails from Contact Us form.

However, when the user fills out the form get the message: SMTP connect() failed

I tried to change the settings on joomla to send emails from Gmail.
Here are the mail settings of the configuration.php file:
Mail from: [email protected] mailer = smtp sendmail = /usr/sbin/sendmail fromname = myname smtpuser: gmail username smtp password: gmail password smtp security: TLS SMTP Host: smtp.gmail.com

I can connect via SSH to the terminal of my server

After doing so and executing the Telnet command accessing smtp.gmail.com via port 587, this is what I get:

myserver:~# telnet smtp.gmail.com 587 Trying 173.194.79.108... Connected to gmail-smtp-msa.l.google.com. Escape character is '^]'.

At least we can see that it is connecting.

As far as the mail logs goes here I've looked at them and only can see sender of Joomla and not from myself

Thanks

4
  • What do you have on smtp user? Is it your full Gmail email address or just username without @gmail.com?
    – webchun
    Nov 11, 2016 at 2:56
  • Good call @webchun ... username should be '[email protected]', not just 'user'.
    – Mikan
    Nov 11, 2016 at 8:50
  • Good thinking @webchun In smtp user I had just my username without the gmail. Following your suggestions, I changed it to ‘[email protected]’ instead of ‘user’, restarted the apache server, but it still doesn’t work. I get the same: SMTP connect() failed. message
    – mikeli
    Nov 11, 2016 at 12:44
  • One thing to check is Google restricting access from "less secure" applications. You may (should) get a warning email from google that you tried to access w/ an insecure app but you have to check the underlying gmail account to see that (which often I miss, because the gmail account is just for teh web app and not set up on my phone or desktop client for example.) Find ore info on "less secure apps" here: support.google.com/accounts/answer/6010255?hl=en
    – JoelAZ
    Feb 6, 2018 at 8:54

3 Answers 3

2

Here are the official Joomla! Docs for anyone else looking in the future:

https://docs.joomla.org/How_do_I_use_Gmail_as_my_mail_server%3F

How do I use Gmail as my mail server?

If you have a working Gmail account you can use Gmail as your mail server by setting it in the global configuration.

On the server tab set the following:

Mailer: SMTP
SMTP Host: smtp.gmail.com
SMTP Port 465
SMTP Security: SSL/TLS
SMTP Authentication: Yes
Set the next two lines with your information. You need to use an app specific password (ASP), described below.
SMTP Username: your gmail username
SMTP Password: your gmail password

The following are also working combinations:

SMTP Port 587
SMTP Security: STARTTLS

SMTP Port 25
SMTP Security: STARTTLS

The SSL module does not need to be enabled in Apache.

The OpenSSL extension needs to be enabled in PHP. The details can be found at http://www.php.net/manual/en/openssl.installation.php

If you are using WAMP on Windows, the openssl module is not enabled by default and you need to enable it. To do this:

Open the php.ini file and uncomment the line extension=php_openssl.dll by removing the semicolon ; from the beginning of the line.
Save the php.ini file and restart the Apache service.

Note

Note that if you use 2-step verification in Gmail, you need to add a new password in Settings - Accounts - Change accounts settings - Other Google Account settings - Security - 2-step verification - Manage your application specific passwords.

When the new Application Specific Password (ASP) is presented in groups of four characters separated by spaces, make sure that you do NOT enter the spaces into the SMTP password in the mail server settings in Joomla.

You will need to make sure 2 Factor authentication is turned off:

https://support.google.com/accounts/answer/1070457

https://support.google.com/accounts/answer/1064203?hl=en&ref_topic=7189195

Instructions via computer

Open your Google Account.
In the "Security" section, select 2-Step Verification. You might need to sign in.
Select Turn off.
A pop-up window will appear to confirm that you want to turn off 2-Step Verification. Select Turn off.

Destroy all the backup codes that you've saved for signing in to this account. Revoking app passwords you no longer use

If you used app passwords to let apps access your Google Account, you may see errors when you turn off 2-Step verification. If this happens, re-enter your Google Account password.

We recommend you revoke your app passwords:

Sign in to your Google Account.
In the "Security" section, select Signing in to Google.
Choose App passwords. You might need to sign in.
Next to an application or device, select Remove Remove .

The next time you sign in to the app or device, you'll be asked to enter your Google Account username and password. If an app doesn't ask right away, it might take longer to recognize that its app password has been revoked.

You will need to set up an App specific password (but can only do so if the 2FA is turned off)

Don't forget you have account level 2FA and email specific 2FA https://support.google.com/accounts/answer/185833

Sign in using App Passwords

An App Password is a 16-digit passcode that gives a non-Google app or device permission to access your Google Account. App Passwords can only be used with accounts that have 2-Step Verification turned on. When to use App Passwords

To help keep your account secure, use "Sign in with Google" to connect apps to your Google Account. If the app you’re using doesn’t offer this option, you can either:

Use App Passwords to connect to your Google Account
Switch to a more secure app

Create & use App Passwords

Note: If you use 2-Step-Verification and are seeing a "password incorrect" error when trying to access your Google Account, an App Password may solve the problem.

Go to your Google Account.
On the left navigation panel, choose Security.
On the "Signing in to Google" panel, choose App Passwords. If you don’t see this option:
    2-Step Verification is not set up for your account.
    2-Step Verification is set up for security keys only.
    Your account is through work, school, or other organization.
    You’ve turned on Advanced Protection for your account.
At the bottom, choose Select app and choose the app you’re using.
Choose Select device and choose the device you’re using.
Choose Generate.
Follow the instructions to enter the App Password. The App Password is the 16-character code in the yellow bar on your device.
Choose Done.

Most of the time, you’ll only have to enter an App Password once per app or device, so don’t worry about memorizing it.

And Finally

In my case my host had disabled SMTP email sending for security purposes I had to contact them and they enabled it for my account.

2
  • 1
    I haven't read it thoroughly, but thanks for taking the time to share your knowledge and experience.
    – FFrewin
    Jul 1, 2020 at 17:44
  • 1
    This is not my knowledge, and only a small bit of experience. I mainly copied and pasted the Joomla! and Google docs here as is best practice rather than simply linking to the docs. Thanks to whoever did it the first time around :)
    – Eoin
    Jul 2, 2020 at 19:27
1

IMAP/SMTP do not work be default with Gmail accounts.

Probably need to enable less secure apps: https://support.google.com/accounts/answer/6010255?hl=en

0

I was once having the same problem, but not with Joomla (other platform).

The issue was suddenly happened (it worked good before). My server were able to connect gmail via telnet just like yours but when script was executed it's always returned SMTP connect failed.

I spent many hours to troubleshoot this with no luck. I checked the script, all firewall rules and everything was fine. And later, that was ended with my gmail account suspended by google said I’m violating their tos without any good reason.

So I think this issue probably comes from the google end. They are probably becoming too strict. I'd suggest you to use dedicated email service such as Sendgrid or Amazon SES (they are cheap) that indeed provide service for that purpose (transactional email service) while maybe google doesn't want their service to be used for that purpose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.