Using GMail SMTP in AEM 6.0


If you are trying to use Gmail SMTP in AEM 6.0 or any Java based Mail Client and see above error logs.. authentication failed…not able to connect to etc please make sure 2 things are done at your client machine where you are testing. i spend 4 to 5 hours to find the solution.

  1. Disable the firewall on your laptop or PC.
  2. Use following screenshot for SMTP configuration.


Sample code here.

List<InternetAddress> emailRecipients = new ArrayList<InternetAddress>();
try {

private MessageGatewayService messageGatewayService;
private MessageGateway<HtmlEmail> messageGateway;
HtmlEmail email = new HtmlEmail();
emailRecipients.add(new InternetAddress(userName));
email.setSubject(“XXX Password Reset”);

StringBuffer sb = new StringBuffer();

sb.append(“<b>XXX Password Reset</b> <BR> To: “+userName);

messageGateway = messageGatewayService.getGateway(HtmlEmail.class);
} catch (Exception ex) {
LOGGER.debug(” Exception caught in send email” + ex.getMessage());

return false;




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s