5

I can't seem to get outbound email working from my SugarCRM installation, with only the message SMTP connect() failed appearing in the logs.

I've set my smtp server to smtp.gmail.com, email address, password, TLS, port 587. When I go to 'Send Test Email' I get the error.

I've set my local hostname, installed openssl, set the host_name in config.php and included it as a referrer in config_override.php. I've also tried setting SMPTDebug to 2 in SugarPHPMail.php but that seemed to have no effect.

When I run openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587 the output includes Verify return code: 0 (ok) and I don't know where to go from here. I can connect via telnet to that host & port and get a 220 SMTP message back as expected.

I do also have an exchange server available, but haven't been able to get that one working either, and thought Gmail would be more easily-solved.

I'm on Sugar 6.5.26 hosted on Linux (Debian, Raspbian).

Jeremy Jones
  • 4,561
  • 3
  • 16
  • 26
  • Also if I try switching the Authentication setting to None then I do get the Authentication error in the logs, saying authentication required, suggesting that the server is able to open connections ok (at least on port 25, and on port 587 at the command line). – Jeremy Jones Jul 16 '17 at 16:48
  • Unrelated to this question (since you have it solved), I'm curious about your use-case for running Sugar on a RaspberryPi. Any chance you blog/write about it? – Matthew Poer Jul 16 '17 at 18:03

1 Answers1

3

Ok I found the solution while looking for the 'Allow less secure apps' setting in Gmail.

I have two-step authentication switched on in my Gmail account, which will obviously complicate things but had slipped my mind. Therefore I needed to use an app-specific password, and not my normal Gmail password.

As soon as I created an app-specific password in Google (at https://myaccount.google.com/apppasswords) and plugged that into the SugarCRM settings, it worked fine. D'oh!

Jeremy Jones
  • 4,561
  • 3
  • 16
  • 26
  • 2
    +1 for common use case and solution. Gmail seems so easy until you can't find that config. setting. You can also get a clue on this if you set the Sugar error logging level to debug (the PHPMailer class will throw relevant errors and results from the SMTP server). – Matthew Poer Jul 16 '17 at 17:58
  • 1
    @MatthewPoer If I remember correctly the log level `info` is sufficient for logging SMTP connects+problems. However one will probably want to "clean" the log files after, as the SMTP info/debug lines include the used password. – Jay Jul 16 '17 at 18:12
  • `truncate -s0 sugarcrm.log` is a good friend of mine after fixing things like this; for security but also just to remove the noise – Matthew Poer Jul 16 '17 at 19:28