Mail Action: Authentication credentials invalid

hello!
i installed mail action and checked the configuration serveral times, but I still get “535 Authentication credentials invalid” as error. it doesn’t matter if i use tls or ssl, the error remains the same. gmx only offers the following help: https://hilfe.gmx.net/pop-imap/imap/imap-serverdaten.html

mail config:

# The SMTP server hostname, e.g. "smtp.gmail.com"
hostname=mail.gmx.net

# the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS/SSL))
#port=465

# the username and password if the SMTP server requires authentication
username=NAME
password=PASS

# The email address to use for sending mails
from=NAME

# set to "true", if STARTTLS is enabled (not required) for the connection
# (optional, defaults to false)
#tls=true

# set to "true", if SSL negotiation should occur on connection
# do not use both tls=true and ssl=true
# (optional, defaults to false)
ssl=true

# set to "true", if POP before SMTP (another authentication mechanism)
# should be enabled. Username and Password are taken from the above
# configuration (optional, default to false)
popbeforesmtp=false

# Character set used to encode message body
# (optional, if not provided platform default is used)
#charset=

2019-05-13 09:27:25.062 [ERROR] [rg.openhab.action.mail.internal.Mail] - Could not send e-mail to 'MAILTOME@gmx.de'.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.gmx.net:465
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421) ~[?:?]
        at org.apache.commons.mail.Email.send(Email.java:1448) ~[?:?]
        at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:157) ~[?:?]
        at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:89) ~[?:?]
        at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:67) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1086) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1061) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:1047) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:992) ~[?:?]
        at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:151) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:902) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:865) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:224) ~[?:?]
        at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:204) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:447) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:228) ~[?:?]
        at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:226) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:204) ~[?:?]
        at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:190) ~[?:?]
        at org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptImpl.execute(ScriptImpl.java:82) ~[?:?]
        at org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl.lambda$2(RuleEngineImpl.java:341) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: javax.mail.AuthenticationFailedException: 535 Authentication credentials invalid

        at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:809) ~[27:javax.mail:1.4.4]
        at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:752) ~[27:javax.mail:1.4.4]
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669) ~[27:javax.mail:1.4.4]
        at javax.mail.Service.connect(Service.java:317) ~[27:javax.mail:1.4.4]
        at javax.mail.Service.connect(Service.java:176) ~[27:javax.mail:1.4.4]
        at javax.mail.Service.connect(Service.java:125) ~[27:javax.mail:1.4.4]
        at javax.mail.Transport.send0(Transport.java:194) ~[27:javax.mail:1.4.4]
        at javax.mail.Transport.send(Transport.java:124) ~[27:javax.mail:1.4.4]
        at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411) ~[?:?]
        ... 32 more

That link says you should use port 587 and tls, not ssl, or use port 465 and ssl.
In any case I would remove the comment # before the port and set it explicitly.

i had already tried it, but without success. general question: do i have to restart openhab after a config change?

You shouldn’t have to, but doesn’t hurt to try. And while you do, empty cache in the meantime

1 Like

It’s bit hard to tell from the stack trace, but it could be that your mail provider doesn’t support TLS 1.0.

From what I can tell, the underlying libs used by the mail action are an older version that uses TLS 1.0. At least that was my experience recently when the mail action broke for no apparent reason after working for years. A little research with my mail service provider exposed that they had just disabled TLS 1.0.

My solution was to switch to the new mail binding, which works fine (although it does require some minor editing of the rules). If you decide to try the new binding, there are some 3rd party libs that need to be dropped into addons.

@mhilbush thx for your answer! can you tell me the steps to install the new binding? or do you have a link?

Sure, gimme a minute to get the info for you.

@rafael_09 Here you go.

Note: If you’re running the latest 2.5 snapshot, you can install the binding using Paper UI. Otherwise, follow these steps.

  1. Remove v1 mail action.

  2. Download these 3rd party dependencies and place in addons directory.

http://central.maven.org/maven2/org/apache/commons/commons-email/1.5/commons-email-1.5.jar
http://central.maven.org/maven2/com/sun/mail/javax.mail/1.6.2/javax.mail-1.6.2.jar

  1. Download latest snapshot of v2 mail binding and place in addons directory.

https://ci.openhab.org/job/openHAB2-Bundles/lastSuccessfulBuild/artifact/openhab2-addons/bundles/org.openhab.binding.mail/target/org.openhab.binding.mail-2.5.0-SNAPSHOT.jar

  1. In console, verify everything is installed and active.
openhab> list -s | grep mail                                                                            
282 │ Active   │  80 │ 2.5.0.201905040410     │ org.openhab.binding.mail
285 │ Active   │  80 │ 1.6.2                  │ com.sun.mail.javax.mail
286 │ Active   │  80 │ 1.5.0                  │ org.apache.commons.email
  1. In Paper UI, create an SMTP thing and enter all the info needed by your mail service provider.

  2. Modify rule to invoke sendMail like this.

val mailActions = getActions("mail","mail:smtp:mymailserviceprovider")
mailActions.sendMail("me@me.com", "This is the subject line", "This is the mail content.")

thanks for the instructions. however, when setting up the smtp server in the paperui, a “500-internal server” error occurs.
I installed the following additional:
http://repo2.maven.org/maven2/com/sun/activation/javax.activation/1.2.0/javax.activation-1.2.0.jar

nevertheless I get the following error message:

2019-05-13 20:53:08.662 [ERROR] [st.core.internal.thing.ThingResource] - Exception during HTTP PUT request for update config at 'things/mail:smtp:e447b91c/config'
java.lang.IllegalStateException: Thing with UID mail:smtp:e447b91c has no handler attached.
         at
org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.updateConfiguration(ThingRegistryImpl.java:93)
~[?:?]
         at
org.eclipse.smarthome.io.rest.core.internal.thing.ThingResource.updateConfiguration(ThingResource.java:438)
[404:org.eclipse.smarthome.io.rest.core:0.10.0.oh240]
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
         at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[?:?]
         at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:?]
         at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
         at
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
[455:org.glassfish.jersey.core.jersey-common:2.22.2]
         at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
[455:org.glassfish.jersey.core.jersey-common:2.22.2]
         at
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
[455:org.glassfish.jersey.core.jersey-common:2.22.2]
         at
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
[455:org.glassfish.jersey.core.jersey-common:2.22.2]
         at
org.glassfish.jersey.internal.Errors.process(Errors.java:267)
[455:org.glassfish.jersey.core.jersey-common:2.22.2]
         at
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
[455:org.glassfish.jersey.core.jersey-common:2.22.2]
         at
org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
[456:org.glassfish.jersey.core.jersey-server:2.22.2]
         at
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
[453:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
         at
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
[453:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
         at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
[453:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
         at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
[453:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
         at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
[453:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
         at
com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76)
[304:com.eclipsesource.jaxrs.publisher:5.3.1.201602281253]
         at
org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
[369:org.eclipse.jetty.servlet:9.4.11.v20180605]
         at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535)
[369:org.eclipse.jetty.servlet:9.4.11.v20180605]
         at
org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)
[470:org.ops4j.pax.web.pax-web-jetty:7.2.3]
         at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
[366:org.eclipse.jetty.security:9.4.11.v20180605]
         at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293)
[470:org.ops4j.pax.web.pax-web-jetty:7.2.3]
         at
org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
[369:org.eclipse.jetty.servlet:9.4.11.v20180605]
         at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)
[470:org.ops4j.pax.web.pax-web-jetty:7.2.3]
         at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at org.eclipse.jetty.server.Server.handle(Server.java:531)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
[368:org.eclipse.jetty.server:9.4.11.v20180605]
         at
org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
[359:org.eclipse.jetty.io:9.4.11.v20180605]
         at
org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
[359:org.eclipse.jetty.io:9.4.11.v20180605]
         at
org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:291)
[359:org.eclipse.jetty.io:9.4.11.v20180605]
         at
org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:151)
[359:org.eclipse.jetty.io:9.4.11.v20180605]
         at
org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
[359:org.eclipse.jetty.io:9.4.11.v20180605]
         at
org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
[359:org.eclipse.jetty.io:9.4.11.v20180605]
         at
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
[371:org.eclipse.jetty.util:9.4.11.v20180605]
         at
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
[371:org.eclipse.jetty.util:9.4.11.v20180605]
         at
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
[371:org.eclipse.jetty.util:9.4.11.v20180605]
         at
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
[371:org.eclipse.jetty.util:9.4.11.v20180605]
         at
org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
[371:org.eclipse.jetty.util:9.4.11.v20180605]
         at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)
[371:org.eclipse.jetty.util:9.4.11.v20180605]
         at
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)
[371:org.eclipse.jetty.util:9.4.11.v20180605]
         at java.lang.Thread.run(Thread.java:748) [?:?]

I’m not sure what to do about that error. What version of openHAB are you running?

openhab 2.4

I’m not sure what to suggest. I assume you tried a restart?

I have it running on an early 2.5 snapshot (build 1502, before all the reintegration work) as well as a very recent 2.5 snapshot. Maybe there’s a compatibility issue with 2.4.

server has been restarted.
i think i try another mail provider. is gmail supported?

Sorry, but I don’t know.

Yes of course it is. It works well.
Not sure but If I remember, maybe you will have to check this actions.

-1. respect the 2-step verification (https://www.google.com/landing/2step/)
If you don’t respect that you will have an authentification issue

-2.you would have to accept the external connection from a “less secure client” like the OpenHAB email action in the Google Mail settings (https://security.google.com/settings/security/apppasswords) in security

i just found out that there should also be a mail binding in the docs…
mail binding
mail action
i have only set up mail.cfg so far. do i also have to create a new thing to send mails?

You would need to create things only if you’re using the version 2 binding, which you are not (see below).

You may need to update to a recent snapshot release, or wait for the next 2.5 milestone release in order to use the new v2 binding.