Gmail authentication error [Solved]

It looks like I am unable to authenticate with gmail for some reason on. I am running openhab 1.7 on Windows 7. Please note I have tried with and without the domain name “username” and “mailfrom” in the config below.

I also read through this thread as well and it appears someone had similar issue that was on Windows 7 but not sure if this is really a issue or not as this thread is over 2 yrs old.

Anyhow, Here’s my config-
######################## Mail Action configuration ####################################

The SMTP server hostname, e.g. “smtp.gmail.com

mail:hostname=smtp.gmail.com
mail:port=587
mail:username=
mail:password=

The email address to use for sending mails

mail:from=username@gmail.com

set to “true”, if TLS should be used for the connection

(optional, defaults to false)

mail:tls=true

here’s my log:

2015-10-23 12:41:06.114 [ERROR] [nhab.action.mail.internal.Mail] - Could not send e-mail to ‘@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:121) [bundlefile:na]
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:62) [bundlefile:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
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.GeneratedMethodAccessor45.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
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.7.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.GeneratedMethodAccessor44.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
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]
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
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._evaluateIfExpression(XbaseInterpreter.java:329) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
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]
at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
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.evaluate(XbaseInterpreter.java:204) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at org.openhab.model.script.internal.engine.ScriptImpl.execute(ScriptImpl.java:59) [org.openhab.model.script_1.7.1.jar:na]
at org.openhab.core.scriptengine.ScriptExecutionThread.run(ScriptExecutionThread.java:44) [org.openhab.core.scriptengine_1.7.1.jar:na]
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.AuthenticationFailedException: Error authenticating with server)
at javax.mail.Transport.send(Transport.java:163) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Transport.send(Transport.java:48) ~[javax.mail_1.4.0.v201005080615.jar:na]
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232) ~[commons-email-1.2.jar:1.2]
… 41 common frames omitted
Caused by: javax.mail.AuthenticationFailedException: Error authenticating with server
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:402) ~[na:na]
at javax.mail.Service.connect(Service.java:265) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Service.connect(Service.java:85) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Service.connect(Service.java:70) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Transport.send(Transport.java:94) ~[javax.mail_1.4.0.v201005080615.jar:na]
… 43 common frames omitted

Are you using two-factor authentication? If so, your app-specific password may have expired.

Thanks for the reply Steve. I am not using that for this email account.

One more note is that it is working fine with Yahoo email. Only having problem with Gmail for some reason.

Google by default allows only secure apps. I am not sure if openHAB is classified as that if not you need to cnfigure gmail to allow insecure appa as well. See this link for more information.

https://support.google.com/accounts/answer/6010255?hl=en

Thanks Mahesh, that is probably the problem. I see that it was turned on. Since I use that account for others, I’ll just stick with my yahoo one for now.

@mrgrumpy would you be able to test this solution and post the results here? You can turn off access to non secure apps once you test :smile:

Just tested! That was indeed the problem. Thanks again.

Thanks. I just ran into the same issue. Changing the setting fixed the problem.