emphywork
emphywork

Reputation: 448

Grails Send mail form Gmail Business Mail Exception : Authentication failed; nested exception is javax.mail.AuthenticationFailedException

I am trying to send an email using Google's Business email Account.

I am using Grails 3.2.7 and Grails's mail plugin ('org.grails.plugins:mail:2.0.0.RC6'). I am getting the following exception, even though I have set all the authentication credentials and I have set my account to allow less secure apps to access.

org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException

Following are the settings for sending mail

mail {
    host = 'smtp.gmail.com'
    port = 587
    username = "##### BUSINESS EMAIL from GMAIL###"
    password = "PASSWORD"
    props = ["mail.smtp.auth"                  : "true",
             "mail.smtp.socketFactory.port"    : "465",
             "mail.smtp.socketFactory.class"   : "javax.net.ssl.SSLSocketFactory",
             "mail.smtp.socketFactory.fallback": "false"]
}

Anyone can help on why is it not sending email and failing on Authentication.

Please note that if I try to send the email using normal GMAIL account with same settings it is working fine.

Additional information I am trying to send email to other domains from sender email being "BUSINESS EMAIL from GMAIL"

Upvotes: 0

Views: 290

Answers (1)

Rafiq
Rafiq

Reputation: 750

I have sent mail using Grails 3.1.8 and dependency
compile "org.grails.plugins:mail:2.0.0.RC2".

You can try it in grails 3.2.7

  mail {
    host = "smtp.gmail.com"
    port = 465
    username = "[email protected]"
    password = "password"
    ssl = "on"
    props = ["mail.smtp.auth"                   : "true",
             "mail.smtp.port"                   : "465",
             "mail.smtp.socketFactory.port"     : "465",
             "mail.smtp.socketFactory.class"    : "javax.net.ssl.SSLSocketFactory",
             "mail.imap.ssl.checkserveridentity": "false",
             "mail.imap.ssl.trust"              : "*",
             "mail.smtp.socketFactory.fallback" : "true"]
 }

Upvotes: 2

Related Questions