Sending mail with Gmail account gives AuthenticationFailedException

I tried to send an email from a Gmailaccount but I receive the exception below:

My setup

openhab.cfg

mail:hostname=smtp.gmail.com mail:port=587 mail:username=mymail@gmail.com mail:password=mypassword mail:from=mymail@gmail.com mail:tls=true

Addon

I installed org.openhab.action.mail-1.8.1.jar via apt-get and this jar was then installed in the /usr/share/openhab/addons folder.

Gmail settings

I allowed 'less secure applications'

Trigger testcase

I used a rule to send the email.

I doublechecked the SMTP config by trying to send an email (SMTP) via a Python script with the same emailaddress as above and that works very well.

Does anyone have a suggestion for this issue?

20:07:36.015 [ERROR] [nhab.action.mail.internal.Mail:159 ] - Could not send e-mail to 'testemail@gmail.com'. org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587 at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242) ~[commons-email-1.2.jar:1.2] at org.apache.commons.mail.Email.send(Email.java:1267) ~[commons-email-1.2.jar:1.2] at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:155) [bundlefile:na] at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:90) [bundlefile:na] at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:65) [bundlefile:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65] at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na] at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:713) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65] at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) [org.eclipse.xtext.util_2.3.0.v201206120633.jar:na] at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:69) [org.openhab.model.script_1.8.1.jar:na] at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65] at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) [org.eclipse.xtext.util_2.3.0.v201206120633.jar:na] at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na] at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na] </code

Hello,

I have the same settings as you in openhab.cfg and using gmail also with success. I had a quite similar message than yours when I was sending too many emails per day.

Despite this kind of problem did you check this article (https://support.google.com/a/answer/176600?hl=en) and in particular things related to authentication (for instance are you with a dynamic IP adress)?

Thx for your response 1technophile. I think my problem was related to yours. I just saw in my inbox from my recovery emailaccount the following message:

Sign-in attempt prevented Someone just tried to sign in to your Google Account mymail@gmail.com from an app that doesn't meet modern security standards. Details: Monday, March 21, 2016 8:19 PM (Central European Standard Time) Antwerp, Belgium* We strongly recommend that you use a secure app, like Gmail, to access your account. All apps made by Google meet these security standards. Using a less secure app, on the other hand, could leave your account vulnerable. Learn more.

Google stopped this sign-in attempt, but you should review your recently used devices:

REVIEW YOUR DEVICES NOW

After I reviewed my device, the problem was solved and I could succesfully send emails via OpenHab.