E-WF: JavaMail Exception: javax.mail.AuthenticationFailedException, Error Using Gmail SMTP Server (Doc ID 1436910.1)

Last updated on SEPTEMBER 02, 2016

Applies to:

PeopleSoft Enterprise PT PeopleTools - Version 8.50 and later
Information in this document applies to any platform.

Symptoms

Google GMAIL SMTP server is used as SMTP server with PeopleSoft Application.

Here are the SMTP settings as per Google
Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587

Attempt to use MCF to send email from PeopleCode results with the following returned;

JavaMail Exception: javax.mail.AuthenticationFailedException, Message: javax.mail.AuthenticationFailedException.



The  SMTP log, shows the following relevant data:

1. Symptom 1

Mon Feb 13 11:50:31 CST 2012 Mon Feb 13 11:50:31 CST 2012 DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false
DEBUG SMTP: exception reading response: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Untrusted Server Certificate Chain
DEBUG SMTP: useEhlo true, useAuth true




The User ID and Password are correct.


2. Symptom 2:

No errors and the process is just hung.
......
Fri Sep 06 11:41:15 IST 2013 DEBUG MCFJEMAIL: Inside MCFOutboundEmail.send method
Fri Sep 06 11:41:15 IST 2013 DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
Fri Sep 06 11:41:15 IST 2013 DEBUG MCFJEMAIL: Initiating SMTP connection with  primary server: 'smtp.gmail.com' port '465' user 'peoplesoftcamp@gmail.com'
Fri Sep 06 11:41:15 IST 2013 DEBUG SMTP: useEhlo true, useAuth true
Fri Sep 06 11:41:15 IST 2013 DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false

.......

 

 

The sample PeopleCode is given below;

import PT_MCF_MAIL:*;

Local PT_MCF_MAIL:MCFOutboundEmail &eMail = create PT_MCF_MAIL:MCFOutboundEmail();

&eMail.Recipients = "psftadmin@company.com";
&eMail.CC = "";
&eMail.BCC = "";
&eMail.From = "psftadmin@company.com";
&eMail.ReplyTo = "psftadmin@company.com";

&eMail.Subject = "test subject"; /* email subject line */
&eMail.Text = "test body"; /* email body text */

&eMail.SMTPServer = "smtp.gmail.com";
&eMail.IsAuthenticationReqd = True;
&eMail.SMTPUserName = "psftadmin@company.com";
&eMail.SMTPUserPassword = "validPassword";
&eMail.SMTPUseSSL = "Y";
&eMail.SMTPSSLPort = 465;

Local integer &resp = &eMail.Send();




ERROR
-----------------------

JavaMail Exception: javax.mail.AuthenticationFailedException, Message: javax.mail.AuthenticationFailedException.

And java.security.cert.CertificateException: Untrusted Server Certificate Chain.


The issue can be reproduced at will with the following steps:


1. Set smtp.gmail.com as SMTPServer with port 465 as SMTPPort
2. Send an email using MCFOutboundEmail classes.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms