kamax-matrix / mxisd

Federated Matrix Identity Server
GNU Affero General Public License v3.0
224 stars 115 forks source link

Failing to send Email notification without SMTP authentication #100

Closed jkms closed 6 years ago

jkms commented 6 years ago
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_191]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_191]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.14.jar!/:8.5.14]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at java.lang.Thread.run(Thread.java:748) [na:1.8.0_191]
Nov 29 22:11:22 MatrixHost mxisd[32574]: Caused by: javax.mail.AuthenticationFailedException: No authentication mechanisms supported by both server and client
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:847) ~[javax.mail-1.5.6.jar!/:1.5.6]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:748) ~[javax.mail-1.5.6.jar!/:1.5.6]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at javax.mail.Service.connect(Service.java:366) ~[javax.mail-1.5.6.jar!/:1.5.6]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011at io.kamax.mxisd.threepid.connector.email.EmailSmtpConnector.send(EmailSmtpConnector.java:94) ~[classes!/:na]
Nov 29 22:11:22 MatrixHost mxisd[32574]: #011... 60 common frames omitted
Nov 29 22:11:22 MatrixHost mxisd[32574]: .473  INFO [nio-8090-exec-9]     i.k.m.c.DefaultExceptionHandler : Request POST http://matrix.domain.com/_matrix/identity/api/v1/store-invite - Error M_UNKNOWN: Unable to send e-mail invite to user@domain.com

mxisd.yaml:

#################################################
# Notifications for invites/addition to profile #
#################################################

#### E-mail invite sender
# SMTP host
threepid.medium.email.connectors.smtp.host: "smtp.example.com"

# SMTP port
threepid.medium.email.connectors.smtp.port: 25

# TLS mode for the connection.
threepid.medium.email.connectors.smtp.tls: 0

# Login for SMTP
# threepid.medium.email.connectors.smtp.login: "matrix@matrix.domain.com"

# Password for the account
# threepid.medium.email.connectors.smtp.password: "ThePassword"

# The e-mail to send as.
threepid.medium.email.identity.from: 'matrix@matrix.domain.com'
threepid.medium:
  email:
    identity:
      from: 'matrix@matrix.domain.com'
      name: 'Matrix Chat'
    connector: 'smtp'
    generator: 'template'
threepid.medium.email:
  generators:
    template:
      invite: '/etc/mxisd/invite-template.eml'
      session:
        validation:
          local: '/etc/mxisd/validate-local-template.eml'
          remote: 'etc/mxisd/validate-remote-template.eml'
      generic:
        matrixId: '/etc/mxisd/mxid-invite-template.eml'

The obvious clue is javax.mail.AuthenticationFailedException: No authentication mechanisms supported by both server and client. I suspect a bug that isn't allowing for SMTP servers that don't require authentication (as is the case with my SMTP server)?

maxidorius commented 6 years ago

If your server doesn't need authentication, remove the SMTP login and password config keys and it should work.

maxidorius commented 6 years ago

Ah nevermind, I just realized you commented them out in the config. Seems like I need to dig on this too! Will get back to you ASAP...

maxidorius commented 6 years ago

Good catch, it's indeed a bug in mxisd. Could you tell me how you install mxisd so I can provide you with a testing version?

jkms commented 6 years ago

deb package.

maxidorius commented 6 years ago

@jkms Try this build please, no change to your config: https://matrix.kamax.io/download/mxisd_1.2.0-7-g623c7b1_all.deb

jkms commented 6 years ago

Bingo! that worked!

maxidorius commented 6 years ago

Awesome! thanks for the report and the fast check!

jkms commented 6 years ago

Thanks for the fast fix!