Neron Neron -4 years ago 159
Java Question

Spring Mail Authentication Error

I am using spring 3.1 in my project and in order to send email, I am using spring mail. When I am trying to send an email, I a─▒ways get this error:

org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client

My mail server does not require a username/ password and this error seems normal according to this fact. But the case is; I could not find a way to not to pass username/password in spring mail's org.springframework.mail.javamail.JavaMailSenderImpl class.

My config is :

<jee:jndi-lookup id="mailSession" jndi-name="${}" cache="true"/>

<bean id="jndiMailSender" class="">
<property name="session" ref="mailSession"/>
<property name="defaultEncoding" value="${mail.defaultEncoding}"/>
<property name="username" value="${abc.mail.username}"/>
<property name="password" value="${abc.mail.password}"/>
<property name="mailMasterAdress" value="${abc.mail.mailMasterAdress}"/>

Mailserver is in weblogic and it's configs are: mail.transport.protocol=smtp

Any ideas?

Answer Source

Use these properties:

By default, gmail does not allow less secure apps to get authenticated. You need to turn on the option in you gmail account to allow less secure apps to get authenticated.

Follow these steps:

1.Login to Gmail. 
2.Access the URL as 
3.Select "Turn on"

Try running your code again, it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download