Unable to set EMails Smtp setup of GMAIL

Hello

I have followed all gmail smtp setup steps. I am getting below error.

Sorry, something went wrong. Please try again.

In Log section I am getting below logs

Jun 27 10:25:00 ERROR metabase.email :: Error testing SMTP connection
Jun 27 10:25:00 ERROR metabase.email :: Error testing SMTP connection
Jun 27 10:25:01 ERROR metabase.email :: Error testing SMTP connection
Jun 27 10:25:01 ERROR metabase.email :: Error testing SMTP connection
Jun 27 10:25:02 WARN metabase.api.email :: Problem connecting to mail server: Couldn’t connect to host, port: smtp.gmail.com, 465; timeout 1000
Jun 27 10:25:02 ERROR metabase.middleware :: PUT /api/email 500 (7 s) (0 DB calls).

Can somebody guide me how to do this

Are you using credentials linked to an https://gsuite.google.com/ account? (formerly known as Google Apps). I don’t think it works with a personal GMail account.

Make sure you don’t have a firewall issue with an outgoing connection from this port - can you e.g. connect to the same port from a telnet client? (you didn’t describe where/how you deployed Metabase. I’e. operating system/ Metabase.jar or Docker etc. - so it’s hard to give more specific advice)

I have deployed metabase using do docker command.

I don’t have firewall issue same gmail account detail I am using for Mail sending using PHP Mail sender.

I’m having the same issue. Guaranteed my user/pass are correct for Google Apps.

Using:
Host: smtp.gmail.com
Port: 465
Security TLS

Error: Sorry, something went wrong. Please try again.

Attempted with new settings based on Google's documentation here and have a new error:

No matching clause: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu4 534-5.7.14 ESK-IhjRb53BuL0h2tmUrYOO_oroZvYmAhp4Fbiy-JGs9VPZYdmn7cNCFq_tOfXICRwOcU 534-5.7.14 PcH2nJe9cvNnBDBBnFFM2S9u6s2nOlnYNimzmndK6t3RgptFKI_Hx7wnUNVHjG5K53cgNX 534-5.7.14 HKEwHZnN1st3SM6-02VJJeVyLR8BOHxxwhU8xRNn-ef5CuFQwvstaaf9HhORdY3cwPglMB 534-5.7.14 tBy6lPX0vGjQp8q2Z_6b765xx99VE> Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 q13-v6sm4274655qkl.97 - gsmtp

Ok, this seems to be progress towards something more actionable now!

The link within the new error message from google has got some troubleshooting steps. Does following those yield anything for any of you guys?

https://support.google.com/mail/answer/7126229

Hi, I tried those steps and in fact those are how I configured originally. I’m getting the UI error of “Sorry, something went wrong. Please try again.” and the log below…any ideas?

[22534ef6-46be-4901-96a3-c4da657024e4] 2021-01-15T03:07:34+00:00 WARN metabase.email Failed to send email
javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2046)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:711)
at javax.mail.Service.connect(Service.java:366)
at postal.smtp$smtp_send_STAR_.invokeStatic(smtp.clj:33)
at postal.smtp$smtp_send_STAR_.invoke(smtp.clj:29)
at postal.smtp$smtp_send.invokeStatic(smtp.clj:58)
at postal.smtp$smtp_send.doInvoke(smtp.clj:39)
at clojure.lang.RestFn.invoke(RestFn.java:423)
at postal.core$send_message.invokeStatic(core.clj:36)
at postal.core$send_message.invoke(core.clj:29)
at metabase.email$fn__47434$send_message_or_throw_BANG___47439$fn__47443.invoke(email.clj:99)
at metabase.email$fn__47434$send_message_or_throw_BANG___47439.invoke(email.clj:90)
at metabase.email$send_message_BANG_.invokeStatic(email.clj:124)
at metabase.email$send_message_BANG_.doInvoke(email.clj:109)
at clojure.lang.RestFn.invoke(RestFn.java:619)
at metabase.api.email$fn__60453.invokeStatic(email.clj:108)
at metabase.api.email$fn__60453.invoke(email.clj:104)
at compojure.core$wrap_response$fn__1993.invoke(core.clj:160)
at compojure.core$wrap_route_middleware$fn__1977.invoke(core.clj:132)
at compojure.core$wrap_route_info$fn__1982.invoke(core.clj:139)
at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:151)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005.invoke(core.clj:200)
at metabase.middleware.auth$enforce_authentication$fn__72912.invoke(auth.clj:14)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005.invoke(core.clj:200)
at compojure.core$make_context$handler__2033.invoke(core.clj:287)
at compojure.core$make_context$fn__2035.invoke(core.clj:296)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$make_context$fn__2035.invoke(core.clj:297)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at metabase.api.routes$fn__73033$fn__73035.invoke(routes.clj:73)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005.invoke(core.clj:200)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:665)
at clojure.core$apply.invoke(core.clj:660)
at metabase.routes$fn__74362$fn__74363.doInvoke(routes.clj:60)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005.invoke(core.clj:200)
at compojure.core$make_context$handler__2033.invoke(core.clj:287)
at compojure.core$make_context$fn__2035.invoke(core.clj:296)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:153)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:153)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:153)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
at metabase.routes$fn__74350$fn__74352.invoke(routes.clj:44)
at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
at compojure.core$routes$fn__2005.invoke(core.clj:200)
at metabase.middleware.exceptions$catch_uncaught_exceptions$fn__73024.invoke(exceptions.clj:96)
at metabase.middleware.exceptions$catch_api_exceptions$fn__73021.invoke(exceptions.clj:84)
at metabase.middleware.log$log_api_call$fn__74810$fn__74811.invoke(log.clj:197)
at toucan.db$_do_with_call_counting.invokeStatic(db.clj:216)
at toucan.db$_do_with_call_counting.invoke(db.clj:209)
at metabase.middleware.log$log_api_call$fn__74810.invoke(log.clj:191)
at metabase.middleware.security$add_security_headers$fn__72987.invoke(security.clj:143)
at metabase.middleware.json$wrap_json_body$fn__74513.invoke(json.clj:64)
at metabase.middleware.json$wrap_streamed_json_response$fn__74531.invoke(json.clj:100)
at ring.middleware.keyword_params$wrap_keyword_params$fn__75076.invoke(keyword_params.clj:55)
at ring.middleware.params$wrap_params$fn__75092.invoke(params.clj:69)
at metabase.middleware.misc$maybe_set_site_url$fn__34513.invoke(misc.clj:59)
at metabase.middleware.session$bind_current_user$fn__69491$fn__69492.invoke(session.clj:278)
at metabase.middleware.session$do_with_current_user.invokeStatic(session.clj:260)
at metabase.middleware.session$do_with_current_user.invoke(session.clj:252)
at metabase.middleware.session$bind_current_user$fn__69491.invoke(session.clj:277)
at metabase.middleware.session$wrap_current_user_info$fn__69478.invoke(session.clj:238)
at metabase.middleware.session$wrap_session_id$fn__69464.invoke(session.clj:184)
at metabase.middleware.auth$wrap_api_key$fn__72920.invoke(auth.clj:27)
at ring.middleware.cookies$wrap_cookies$fn__74996.invoke(cookies.clj:216)
at metabase.middleware.misc$add_content_type$fn__34498.invoke(misc.clj:28)
at metabase.middleware.misc$disable_streaming_buffering$fn__34521.invoke(misc.clj:76)
at ring.middleware.gzip$wrap_gzip$fn__75038.invoke(gzip.clj:86)
at metabase.middleware.misc$bind_request$fn__34524.invoke(misc.clj:93)
at metabase.middleware.ssl$redirect_to_https_middleware$fn__74827.invoke(ssl.clj:39)
at metabase.server$async_proxy_handler$fn__74588.invoke(server.clj:72)
at metabase.server.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alert.createSSLException(Unknown Source)
at sun.security.ssl.TransportContext.fatal(Unknown Source)
at sun.security.ssl.TransportContext.fatal(Unknown Source)
at sun.security.ssl.TransportContext.fatal(Unknown Source)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(Unknown Source)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(Unknown Source)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(Unknown Source)
at sun.security.ssl.SSLHandshake.consume(Unknown Source)
at sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
at sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
at sun.security.ssl.TransportContext.dispatch(Unknown Source)
at sun.security.ssl.SSLTransport.decode(Unknown Source)
at sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:598)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:525)
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2041)
… 124 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
… 139 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
… 145 more
[22534ef6-46be-4901-96a3-c4da657024e4] 2021-01-15T03:07:34+00:00 WARN metabase.api.email Problem connecting to mail server: Could not convert socket to TLS
[22534ef6-46be-4901-96a3-c4da657024e4] 2021-01-15T03:07:34+00:00 ERROR metabase.middleware.log POST /api/email/test 500 159.6 ms (1 DB calls)
{:message “Sorry, something went wrong. Please try again.”}

@Poqery
Please post “Diagnostic Info” from Admin > Troubleshooting. Latest release is 0.37.6
It looks like a different problem than this topic. If your SMTP provider supports TLS (which they should), then select that in the Metabase email settings.

Hi Flamber, sorry for the delay, the details are below. I’m setting it up with GMail so:
SMTP Host: smtp.gmail.com
SMTP Port: 587
SMTP Security: tried both TLS and StartTLS
SMTP username and From address are both the same.

{
“browser-info”: {
“language”: “en-GB”,
“platform”: “Win32”,
“userAgent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36”,
“vendor”: “Google Inc.”
},
“system-info”: {
“file.encoding”: “Cp1252”,
“java.runtime.name”: “Java™ SE Runtime Environment”,
“java.runtime.version”: “1.8.0_271-b09”,
“java.vendor”: “Oracle Corporation”,
“java.vendor.url”: “http://java.oracle.com/”,
“java.version”: “1.8.0_271”,
“java.vm.name”: “Java HotSpot™ 64-Bit Server VM”,
“java.vm.version”: “25.271-b09”,
“os.name”: “Windows 10”,
“os.version”: “10.0”,
“user.language”: “en”,
“user.timezone”: “Europe/London”
},
“metabase-info”: {
“databases”: [
“h2”,
“mysql”
],
“hosting-env”: “unknown”,
“application-database”: “h2”,
“application-database-details”: {
“database”: {
“name”: “H2”,
“version”: “1.4.197 (2018-03-18)”
},
“jdbc-driver”: {
“name”: “H2 JDBC Driver”,
“version”: “1.4.197 (2018-03-18)”
}
},
“run-mode”: “prod”,
“version”: {
“tag”: “v0.37.8”,
“date”: “2021-01-26”,
“branch”: “release-x.37.x”,
“hash”: “490cea7”
},
“settings”: {
“report-timezone”: null
}
}
}

@Poqery

  1. Migrate away from H2 if you’re using Metabase in production:
    https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html
  2. Try with Java 11:
    https://www.metabase.com/docs/latest/operations-guide/java-versions.html
  3. Make sure that you don’t have any “intelligent” firewall/antivirus that intercepts the connection and might cause the problem.

Hi Flamber,

I was on Oracle’s Java version 8 but I dont think that reflects how old it was as they appear to be on different version numbers. Nonetheless I uninstalled it and installed AdoptOpenJDK.

That didnt help.

I use Avast and turned that off for 10 minutes and guess what…It worked! I dont understand why it blocks that connection since it isnt reporting anything blocked etc. Nonetheless I will figure that out on my own and thank you for all your help!

Just a quick note for any other Avast antivirus users.

Setting an exception to the metabase.jar file didn’t work.

In the end I had to go into Menu>Settings>Protection>CoreShields then click the “Mail Shield” tab, untick “Scan outbound emails (SMTP)”

1 Like

@Poqery Perfect, and thank you for reporting back - if you search the forum, you would have found this:
Using regular gmail as email sender