Support Article
Gmail MailConnectException: Couldn't connect to host, port: smtp
Summary
When attempting to send email from inside the Pega 7 Platform using a Google account (Gmail) and accessing a Google SMTP mail transfer agent (MTA), the administrator observed the error:
Caught com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 25; timeout 60000
When checking the Email Integration setup, the administrator saw the Failure message:
MessagingException caught connecting to email server: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout 60000;
Here's the nested exception:
java.net.UnknownHostException: smtp.gmail.com
The Pega log shows multiple errors.
Error Messages
2016-06-21 05:58:04,817 [ PegaRULES-Batch-1] [ STANDARD] [ ] [leManagerForFS:07.21] (pega_integrationengine_default) ERROR - Unexpected exception caught while trying to send an email message with sender ID of <[email protected]> and addressee of <[email protected]>:
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. a84sm2192451wma.0 - gsmtp
2016-06-21 06:04:14,568 [http-bio-8080-exec-3] [TABTHREAD3] [ ] [leManagerForFS:07.21] (Activity.Data_EmailAccount.Action) ERROR pega|127.0.0.1 CLMFSSysAdmin - Data-EmailAccount.PegaCLMFS-Work: The server indicated that the authentication credentials for this Email Account are incorrect.
javax.mail.AuthenticationFailedException: [AUTHENTICATIONFAILED] Invalid credentials (Failure)
Steps to Reproduce
Set up your Email integration in Pega to use a GoogleMail (Gmail) account.
Follow the steps in the Help topic:
https://pdn.pega.com/sites/default/files/help_v722/procomhelpmain.htm#data-/data-emailaccount/emailaccount.htm.
Root Cause
A third-party product issue
Google enforces strict security that cannot be achieved with JavaMail (used internally on the Pega 7 Platform) in its default configuration.
To be able to use JavaMail to send emails using Google SMTP MTA, you will need to consider lessening the Google security constraints.
However, using Port 25 is a bad idea for the Gmail SMTP server. Many corporate networks' firewalls redirect or block Port 25. Port 25 is rarely used for production environments. In most cases, Gmail is used for testing only. Here are the correct options:
- Port 587 - SSL checkbox not checked - uses STARTTLS
- Port 465- SSL checkbox checked - uses SMTPS
Resolution
Consider the following approaches and choose the one that best suits your needs:
- If you choose to send email through a Google SMTP MTA, follow the guidance in Google Account Help:
Search the the Google Support site for Google Account Help topic, Allowing less secure apps to access your account (Answer 6010255?hl). - Best Practice: Enable 2-step verification in Gmail and then assign Pega its own application password.
See these PDN references:
https://pdn.pega.com/community/product-support/question/gmail-email-integration-javanetconnectexception-connection
https://pdn.pega.com/troubleshooting-common-email-issues/troubleshooting-common-email-issues
Published April 21, 2017 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.