I have the following configuration in my server.xml
<Resource name="mail/Session"
auth="Container"
type="javax.mail.Session"
mail.transport.protocol="smtp"
mail.smtp.starttls.enable = "true"
mail.smtp.socketFactory.class = "javax.net.ssl.SSLSocketFactory"
mail.smtp.socketFactory.port="465"
mail.smtp.host="smtp.gmail.com"
mail.smtp.port="465"
mail.smtp.user="[email protected]"
mail.smtp.auth="true"
password="xyz"
/>
This is working perfectly. But if I change it to my Yahoo account at smtp.mail.yahoo.com with the user name and password then I keep getting authentication failed.
Why is this happening? Should I enable something on yahoo or am I doing something wrong?
Yaah! you are right. It's game of enabling something in your email account settings. Everything is fine in your server.xml setting. only you need to provide access privilege for "less secured apps", as gmail blocks less secured them throwing Authentication Exception. So just enable "less secure app access" here at https://myaccount.google.com/lesssecureapps and will work for gmail.
Since you said, for gmail, its working, then you must have already done this setting.
So, Only you have to find allow access for "yahoo" accounts also as you did for gmail accounts. you can do this here at http://help.inspectionsupport.net/isn-settings/enable-less-secure-apps-for-smtp-use-isn-yahoo-mail OR from official site https://help.yahoo.com/kb/SLN27791.html .This setting is at the bottom of the page.
This should work for you.