Problem with G Suite and Gmail set-up of Outbound emails

hi,
I’ve just installed locally on my Windows PC (Wamp server) a SuiteCRM version 7.9.8.
php 5.6.31
apache 2.4.27
mysql 5.7.19

everything is installed correctly, and now I’m trying to set up Outbound emails from my G Suite Business account.
when I try with:
smtp.gmail.com port 465 and SSL

I get: “Error:SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I’ve also contacted google to set up the account correctly in G Suite and everything is fine from their side.
I’ve disabled 2 step verification as for their request, I’ve forced unsafe apps from the main domain.

Nothing changed.

Other tests:

  • I’ve also tried with TLS, and nothing changed.
  • I’ve tried with a TLS account outlook.com and it works fine
  • I’ve tried with the same G Suite account but with port 25, no ssl, and it works… but it only allows email in same domain.

Any suggestion on how to fix this problem?
thank you,

Giulia

Have you searched these forums for SMTP problems with G Suite? I think I remember somebody discussing this here a few weeks ago… but I’m not sure.

Anyway, you have a debugging procedure here

https://suitecrm.com/forum/suitecrm-7-0-discussion/16507-mail-stopped-working-error-smtp-connect-failed#55682

which usually solves this kind of difficulty.

Warning: don’t post the results from that procedure online, unless you obfuscate your email passwords before posting!

thank you for your quick reply!

I’ve checked a lot of different forums and tried different things, but none worked for me.
I’ve followed the procedure indicated in the post, and I got this (I’ve removed parts with email):

01/09/18 15:34:40 [8636][1][FATAL] ------------ Entering smtpConnect
01/09/18 15:34:40 [8636][1][FATAL] smtpConnect: { 3: Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ( }
01/09/18 15:34:40 [8636][1][FATAL] smtpConnect: { ) }
01/09/18 15:34:40 [8636][1][FATAL] smtpConnect: { 3: Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: }
01/09/18 15:34:40 [8636][1][FATAL] smtpConnect: { error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/09/18 15:34:40 [8636][1][FATAL] smtpConnect: { 3: Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/09/18 15:34:40 [8636][1][FATAL] smtpConnect: { 3: Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/09/18 15:34:40 [8636][1][FATAL] smtpConnect: { 1: SMTP ERROR: Failed to connect to server: (0) }
01/09/18 15:34:40 [8636][1][FATAL] SugarPHPMailer encountered an error: An outgoing mail server is not configured to send emails. Please configure an outgoing mail server or select an outgoing mail server for the mail account that you are using in Settings >> Mail Account.
01/09/18 15:34:40 [8636][1][FATAL] ------------ Exiting smtpConnect
01/09/18 15:34:40 [8636][1][FATAL] SugarPHPMailer encountered an error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { 3: Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ( }
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { ) }
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { 3: Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: }
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { 3: Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { 3: Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { 1: SMTP ERROR: Failed to connect to server: (0) }
01/09/18 15:34:40 [8636][1][FATAL] smtp send: { 3: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting }
01/09/18 15:34:40 [8636][1][FATAL] ------------ Exiting SugarMailer send

do you have any suggestion after seeing this?
Reading online it looks like it’s a coding problem from SuiteCRM…but I’m not that technical do understand it.
Any suggestion helps! thanks,

I don’t think it’s a coding problem in SuiteCRM, I think it’s a certificate configuration problem in your system (that’s what the error seems to be reporting).

Do you really need SSL to connect to them?

If so, have you purchased and installed a certificate identifying your server?

thank you for your feedback again.

It’s a gmail account for business, so a G Suite email address… I tried with a gmail standard address I have and I have the same issue.

Unfortunately I need SSL to send emails outside google domain…
within the domain with 25 port it works…but with the SSL or TLL configuration it doesn’t.

any guess after you know it’s a gmail address?

thank you,

SuiteCRM works fine with Gmail emails.

Different servers demand different security settings. G Suite is probably tighter in terms of security,

Basically, Google’s server doesn’t seem to like the certificate you’re giving it. Did you get a certificate by purchasing, or via Let’s Encrypt?

Or were you just hoping it would work without a certificate? If so, you have to ask G Suite if that is allowed, and what settings you should use.

I do not have experience unfortunately about certificates, I’m sorry if possible can you give some advise on how to proceed?
I’ve searched online but I could not understand exactly what you mean.
I did not get any certificate from G Suite, and we had it since 9 years now.
I’ve already got in contact with G Suite, and checked all security settings on this email account, but they said it’s fine and it’s the lowest possible settings as security so I should be able to access it remotely.

any other suggestion?
thank you,

I’m no good with certificates either. :slight_smile:

But if you can get help with that, you would have additional security, better reputation for sending emails (less risk of being considered spam), and you would probably work around your current problem.

SuiteCRM uses PHPMailer, a 3rd party library to send email. It’s giving back this error about the certificate, so we need to be able to provide something different if we want it to work…


On another front, see this part in my script?

//Use these to override some fields for tests:
//$this->From = 'me@here.com';
//$this->Sender = 'me@here.com';
//$this->Password='wrong';
//$this->FromName = 'My Name';

try filling in your values there, and remove the respective comment marks ("//"). If it starts working, then SuiteCRM is not carrying the correct configurations into that part of the code. You can also try printing out values onto the logs to see what values it’s actually using.

I’m sorry, I saw only now the extra coding to use to try to overwrite values! I’ve filled it and I’ve tried just now.
Still I was not able to send with the same error, it means the problem is before I guess…?
print of values override is fine, as values are correct…

Below the log I got:

01/10/18 07:16:12 [13824][1][FATAL] ------------ Entering SugarMailer send
01/10/18 07:16:12 [13824][1][FATAL] PHPMailer Send Function override: { FromName: test@******* From: test@******* Host: smtp.gmail.com UserName: test@******* }
01/10/18 07:16:12 [13824][1][FATAL] ------------ Entering smtpConnect
01/10/18 07:16:13 [13824][1][FATAL] smtpConnect: { 3: Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ( }
01/10/18 07:16:13 [13824][1][FATAL] smtpConnect: { ) }
01/10/18 07:16:13 [13824][1][FATAL] smtpConnect: { 3: Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: }
01/10/18 07:16:13 [13824][1][FATAL] smtpConnect: { error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/10/18 07:16:13 [13824][1][FATAL] smtpConnect: { 3: Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/10/18 07:16:13 [13824][1][FATAL] smtpConnect: { 3: Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/10/18 07:16:13 [13824][1][FATAL] smtpConnect: { 1: SMTP ERROR: Failed to connect to server: (0) }
01/10/18 07:16:13 [13824][1][FATAL] SugarPHPMailer encountered an error: An outgoing mail server is not configured to send emails. Please configure an outgoing mail server or select an outgoing mail server for the mail account that you are using in Settings >> Mail Account.
01/10/18 07:16:13 [13824][1][FATAL] ------------ Exiting smtpConnect
01/10/18 07:16:13 [13824][1][FATAL] SugarPHPMailer encountered an error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { 3: Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ( }
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { ) }
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { 3: Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: }
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { 3: Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { 3: Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [C:\wamp64\www\SuiteCRM\include\phpmailer\class.smtp.php line 299] }
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { 1: SMTP ERROR: Failed to connect to server: (0) }
01/10/18 07:16:13 [13824][1][FATAL] smtp send: { 3: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting }
01/10/18 07:16:13 [13824][1][FATAL] ------------ Exiting SugarMailer send

any other suggestion? thank you very much.

no other suggestion on this topic?

I read on another thread that G Suite is working in SuiteCRM 7.10 Beta 3. If you’re still only trying out SuiteCRM, not actually sing it in production, then I would suggest that you try the Beta.

If it works, and you still need to go with 7.9.x, you can then search GitHub to try and figure out which change makes a difference…

Also, 7.9.9 is coming out soon, maybe this week, so you could try that one.

thank you for this suggestion, I will try right now and see it if solves the issue.
I’ll update you if it works.

I just finished the testing with the new SuiteCRM 7.10 Beta 3, but I have unfortunately the same problem…no other clues?
does this mean that also the upcoming version 7.9.9 will not solve this problem?
any other suggestion?
thank you very much.

Just fixed this - You have to allow “Less secure applications” in Gmail.

I just fixed this on my end: All I had to was tell G-Suite to allow “Less Secure Apps.”

Can you try adding this to my script somewhere when setting all the fields for the email:


$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

Just to see if it works. It’s a hack, and it lowers security, so try reading about it on the Internet before deciding to use it.

thank you, I’ve added it just after connection parameters, but still no success and same problem…no other ideas?

I’m running out of ideas :frowning: here are 3 more, but they are my last ones:

  1. Try getting a certificate from Let’s Encrypt and configuring it in your server.

  2. The user that says G Suite works for him in 7.10 is in this thread

https://suitecrm.com/forum/suitecrm-beta/17029-suitecrm-7-10-beta-3-released

Maybe try asking him and compare settings.

  1. Other than that, you could try asking in the PHPMailer Github: https://github.com/PHPMailer/PHPMailer/issues
    (try to be thorough and include a full SMTP log, after obfuscating passwords. The passwords are Base64 encoded (which is NOT encryption), and look like this:

CLIENT -> SERVER: AUTH LOGIN
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6"
SERVER -> CLIENT: 334 VXNlcm5hbWU6
CLIENT -> SERVER: bWVAc2l0ZS5jb20=
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6"
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: MTIzNDU2
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "235 2.7.0 Accepted"

Those parts after “CLIENT -> SERVER” are your username and your password, remove them before posting logs there.

no unfortunately this was allowed and checked already at the beginning, so in my case there’s something else.

I experienced the same issue, here is how I solved it.

I get the message “Error:SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting” when I try to send email from SuiteCRM. I am using G Suite and gmail.

• I have “Less secure apps” turned on. https://myaccount.google.com/lesssecureapps
• Configured with smtp.gmail.com, SMTP port 587, SMTP Auth, TLS,
• I have extension=php_openssl.dll enabled in php.ini, and can verify that it is actually enabled in phpinfo().
• Changed $SMTPAutoTLS to “false” in include\phpmailer\class.phpmailer.php

• I added this to line 79 of include/SugarPHPMailer.php and it worked! This let me know that it was indeed the phpmailer blocking the message from being sent because I was using a self-signed certificate.

$mail->SMTPOptions = array(
‘ssl’ => array(
‘verify_peer’ => false,
‘verify_peer_name’ => false,
‘allow_self_signed’ => true
)
);