Elasticsearch gmail config works in windows fails in MAC

I am new to ElasticSearch. My email configurations are working in Windows but same config fails on MAC (Or Ubuntu).

My ElasticSearch.yml:

xpack.license.self_generated.type: basic
xpack.security.enabled: false
        profile: gmail
            auth: true
            starttls.enable: true
            host: smtp.gmail.com
            port: 587
            user: <USER_NAME>@gmail.com

Following documentations from : https://www.elastic.co/guide/en/elastic-stack-overview/current/actions-email.html#configuring-email

There is no firewall on my MAC. I welcome any suggestions.

Error logs:

[2019-04-07T13:37:17,019][ERROR][o.e.x.w.a.e.ExecutableEmailAction] [Cvja-AM] failed to execute action [ inlined /email_1] javax.mail.MessagingException: failed to send email with subject [Test] via account [gmail_account] at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:154) ~[?:?] at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:146) ~[?:?] at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:72) ~[?:?] at org.elasticsearch.xpack.core.watcher.actions.ActionWrapper.execute(ActionWrapper.java:144) [x-pack-core-6.7.0.jar:6.7.0] at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:456) [x-pack-watcher-6.7.0.jar:6.7.0] at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:295) [x-pack-watcher-6.7.0.jar:6.7.0] at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:164)


Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout 120000 at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209) ~[?:?] at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740) ~[?:?] at javax.mail.Service.connect(Service.java:366) ~[?:?]

The error message seems to indicate that your server can not access the smtp server.
I'd suspect a firewall problem...

There are a few things that I tried :

  1. I can access SMTP server using the telnet on my MAC (smtp.gmail.com). I can access it on port 465, meaning that SSL is used.
    However I was not able to find the relevant config for elastic.yml for the port 465.

  2. I was not able to get the elastic config working for neither 587 or 465 ports on Ubuntu. The same works from my windows machine but fails from Linux or Mac. There is no firewall on MAC.

Is there a way I can identify the SMTP server issue ?

I dunno. @spinscale do you know?

The couldnt connect error message usually indicates a network issue/firewall. On your mac you might have tools running like little snitch that do this?

What error do you get when running telnet smtp.gmail.com 587? If that one does not work, then there is indeed a component on your MAC running blocking this.

The exception above indicates, that after 2 minutes no connection could be established. One more thing: Can you restart elasticsearch on your mac and retry? This way, the JVM DNS cache is cleared.

On my Mac: telnet smtp.gmail.com 587:

telnet: connect to address Operation timed out
Trying 2607:f8b0:400e:c00::6d...
telnet: connect to address 2607:f8b0:400e:c00::6d: No route to host
telnet: Unable to connect to remote host

On Ubuntu machine:
Trying 2607:f8b0:400e:c00::6d...
telnet: Unable to connect to remote host: Network is unreachable

I have tried restarting the elasticsearch multiple times.

you will need to resolve the network issue between your mac and gmail before progressing with this further.

when you get something like:

$> telnet smtp.gmail.com 587
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 smtp.gmail.com ESMTP q4sm48571442wrx.25 - gsmtp

you can try again with ES.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.