# Gmail problems

**URL:** https://discuss.elastic.co/t/gmail-problems/213467
**Category:** Elastic Cloud Enterprise (ECE)
**Created:** [December 31, 2019, 6:48pm UTC](https://discuss.elastic.co/t/gmail-problems/213467 "2019-12-31T18:48:06Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Rob\_wylde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rob_wylde/32/58231_2.png) [@Rob\_wylde](https://discuss.elastic.co/u/Rob_wylde)
#### Post date: [December 31, 2019, 6:48pm UTC](https://discuss.elastic.co/t/gmail-problems/213467/1 "2019-12-31T18:48:06Z")

</div>

I'm trying to enable watcher to send email when conditions require an email to be sent. however i'm encounter issues and have been bashing my head against the wall for a while and decided its time to ask for assistance. I'm using an app specific password and i'm 100% confident app security settings in gmail are correct as i'm using this same email address with a different app password to send email from Zabbix and its working.  
Below are my elastic user setting overrides. I do not think xpack.watcher.enabled is required but i saw it in an example and gave it a try.

xpack.watcher.enabled : true  
xpack.notification.email.account:  
gmail\_account:  
profile: gmail  
smtp:  
auth: true  
starttls.enable: true  
host: [smtp.gmail.com](http://smtp.gmail.com)  
port: 587  
user: [donotreply@notimportant.com](mailto:donotreply@notimportant.com)

The password is saved in the key store with the setting name of:  
xpack.notification.email.account.gmail\_account.smtp.secure\_password

Below is the error i find in the logging-and-metrics instances after i push the "send test email" after creating a temporary watcher rule.  
[2019-12-31T18:33:10,986][ERROR][org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction] [instance-0000000005] failed to execute action [_inlined_/email\_1]  
javax.mail.MessagingException: failed to send email with subject [Watch [asf] has exceeded the threshold] via account [work]  
at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:171) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:163) ~[?:?]  
at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:76) ~[?:?]  
at org.elasticsearch.xpack.core.watcher.actions.ActionWrapper.execute(ActionWrapper.java:164) [x-pack-core-7.5.1.jar:7.5.1]  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:534) [x-pack-watcher-7.5.1.jar:7.5.1]

On the nodes running docker  
root@ELK-ECE-NODE-4:~# telnet [smtp.gmail.com](http://smtp.gmail.com) 587  
Trying 74.125.20.109...  
Connected to [smtp.gmail.com](http://smtp.gmail.com).  
Escape character is '^]'.  
220 [smtp.gmail.com](http://smtp.gmail.com) ESMTP c14sm35697244pfn.8 - gsmtp  
^]  
telnet\> quit

However when i tcpdump on the node while snooping for traffic on 587 i see nothing and the above error does not indicate that it is even trying to make a connection.

Any suggestions?  
Thanks

---

<div class="post-metadata">

### Author: ![Alex\_Piggott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_piggott/32/11053_2.png) [@Alex\_Piggott](https://discuss.elastic.co/u/Alex_Piggott)
#### Post date: [January 2, 2020, 6:51pm UTC](https://discuss.elastic.co/t/gmail-problems/213467/2 "2020-01-02T18:51:47Z")

</div>

Ah OK so the clue to what's going on here is `javax.mail.MessagingException: failed to send email with subject [Watch [asf] has exceeded the threshold] via account [work]`

that tells you that the account it's using to send is `work` and not `gmail_account`. The account `work` is some internal config (which in fact isn't used in ECE)

It looks like you just need to add one extra field to your config:

```auto
xpack.notification.email:
  default_account: gmail_account

```

([https://www.elastic.co/guide/en/x-pack/6.2/actions-email.html#configuring-email](https://www.elastic.co/guide/en/x-pack/6.2/actions-email.html#configuring-email))

I see that this isn't included in the closest thing to ECE-specific docs for watcher ([https://www.elastic.co/guide/en/cloud-enterprise/2.4/ece-add-user-settings.html](https://www.elastic.co/guide/en/cloud-enterprise/2.4/ece-add-user-settings.html)) - I'll create an issue to get that fixed, if you can confirm the suggestion works?

---

<div class="post-metadata">

### Author: ![Rob\_wylde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rob_wylde/32/58231_2.png) [@Rob\_wylde](https://discuss.elastic.co/u/Rob_wylde)
#### Post date: [January 2, 2020, 8:25pm UTC](https://discuss.elastic.co/t/gmail-problems/213467/3 "2020-01-02T20:25:55Z")

</div>

Alex,

Yes your solution works. Thank you for this as I've been bashing my head for a while now. 😆

For the benefit of others and myself surely later in life. Here is a working configuration for a custom domain hosted on gmail servers.

```
xpack.notification.email:
  default_account: gmail_account
xpack.notification.email.account:
gmail_account:
    profile: gmail
    smtp:
        auth: true
        starttls.enable: true
        host: smtp.gmail.com
        port: 587
        user: donotreply@notimportant.com

```

Along with the keystore setting of  
`xpack.notification.email.account.gmail_account.smtp.secure_password`

---

<div class="post-metadata">

### Author: ![Amandeep1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amandeep1/32/60846_2.png) [@Amandeep1](https://discuss.elastic.co/u/Amandeep1)
#### Post date: [January 15, 2020, 5:55pm UTC](https://discuss.elastic.co/t/gmail-problems/213467/4 "2020-01-15T17:55:54Z")

</div>

I am also doing exactly the same, but it doesn't work for me. Could you please help?  
Its little Urgent. Thanking you!

javax.mail.MessagingException comes  
Caused by  
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: [smtp.gmail.com](http://smtp.gmail.com), 587; timeout 120000  
Caused by: java.net.ConnectException: Connection timed out: connect

---

<div class="post-metadata">

### Author: ![Alex\_Piggott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_piggott/32/11053_2.png) [@Alex\_Piggott](https://discuss.elastic.co/u/Alex_Piggott)
#### Post date: [January 15, 2020, 7:44pm UTC](https://discuss.elastic.co/t/gmail-problems/213467/5 "2020-01-15T19:44:14Z")

</div>

Ah @Amandeep1 it might be worth opening a new thread for any replies, since this seems like a different problem

The error you are getting indicates that the container hosting ES cannot access `smtp.gmail.com:587` - the container does not have outbound filtering, so this almost certainly means whatever network settings you have at the host level is blocking that?

---

<div class="post-metadata">

### Author: ![Amandeep1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amandeep1/32/60846_2.png) [@Amandeep1](https://discuss.elastic.co/u/Amandeep1)
#### Post date: [January 16, 2020, 5:50am UTC](https://discuss.elastic.co/t/gmail-problems/213467/6 "2020-01-16T05:50:40Z")

</div>

I am running on windows machine. Do I need to change some settings ?

---

<div class="post-metadata">

### Author: ![Rob\_wylde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rob_wylde/32/58231_2.png) [@Rob\_wylde](https://discuss.elastic.co/u/Rob_wylde)
#### Post date: [January 16, 2020, 11:00am UTC](https://discuss.elastic.co/t/gmail-problems/213467/7 "2020-01-16T11:00:26Z")

</div>

@Amandeep1 as @Alex_Piggott pointed out the issue appears to be network related. Check and make sure your cluster devices are able to resolve [smtp.gmail.com](http://smtp.gmail.com) and actually connect to gmail over port 587 via telnet. If those tests are successful and you still can't send mail you should start a new thread.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 30, 2020, 11:00am UTC](https://discuss.elastic.co/t/gmail-problems/213467/8 "2020-01-30T11:00:31Z")

</div>

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