# Watcher email configuration

**URL:** <https://discuss.elastic.co/t/watcher-email-configuration/208356>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [November 18, 2019, 5:06pm UTC](https://discuss.elastic.co/t/watcher-email-configuration/208356 "2019-11-18T17:06:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![faiz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/faiz/32/57554_2.png) [@faiz](https://discuss.elastic.co/u/faiz)\
**Post date:** [November 18, 2019, 5:06pm UTC](https://discuss.elastic.co/t/watcher-email-configuration/208356/1 "2019-11-18T17:06:08Z")

</div>

Hi,

I need to enable the watcher email alert, I have added below setting in the elasticsearch.yml:

**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: "[myuser@gmail.com](mailto:myuser@gmail.com)"\*\*

also have save my secure password in elasticsearch-keystore, PFB:

**[root@myserver bin]# ./elasticsearch-keystore list**  
**warning: ignoring JAVA\_OPTS=-Xms256m -Xmx2048m; pass JVM parameters via ES\_JAVA\_OPTS**  
**bootstrap.password**  
**keystore.seed**  
**xpack.notification.email.account.gmail\_account.smtp.secure\_password**

But when I am trying to test the email service in the watcher, it produces the below exception:

_[2019-11-18T00:20:12,782][ERROR][o.e.x.w.a.e.ExecutableEmailAction] [myserver] failed to execute action [inlined/email\_1]_  
_javax.mail.MessagingException: failed to send email with subject [Watch [abc] has exceeded the threshold] via account [gmail\_account]_

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:153) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:145) ~[?:?]*

```

- 

```
   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-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:516) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:309) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:159) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:605) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:681) [elasticsearch-7.1.1.jar:7.1.1]*

```

- 

```
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]*

```

- 

```
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]*

```

- 

```
   at java.lang.Thread.run(Thread.java:835) [?:?]*

```

_Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: [smtp.gmail.com](http://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) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.Account.lambda$executeConnect$2(Account.java:158) ~[?:?]*

```

- 

```
   at java.security.AccessController.doPrivileged(AccessController.java:551) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.Account.executeConnect(Account.java:157) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.Account.send(Account.java:116) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:151) ~[?:?]*

```

- 

```
   ... 12 more*

```

When I have changed the configuration in yml as below:

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

Then it is reflecting that it couldn't find the password, and getting the exception as below:

_[2019-11-18T18:03:17,790][ERROR][o.e.x.w.a.e.ExecutableEmailAction] [myserver] failed to execute action [inlined/email\_1]_  
_javax.mail.MessagingException: failed to send email with subject [Watch [abac] has exceeded the threshold] via account [work]_

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:153) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:145) ~[?:?]*

```

- 

```
   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-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:516) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:309) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:159) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:605) [x-pack-watcher-7.1.1.jar:7.1.1]*

```

- 

```
   at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:681) [elasticsearch-7.1.1.jar:7.1.1]*

```

- 

```
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]*

```

- 

```
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]*

```

- 

```
   at java.lang.Thread.run(Thread.java:835) [?:?]*

```

_Caused by: javax.mail.AuthenticationFailedException: **failed to connect, no password specified?** _

- 

```
   at javax.mail.Service.connect(Service.java:400) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.Account.lambda$executeConnect$2(Account.java:158) ~[?:?]*

```

- 

```
   at java.security.AccessController.doPrivileged(AccessController.java:551) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.Account.executeConnect(Account.java:157) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.Account.send(Account.java:116) ~[?:?]*

```

- 

```
   at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:151) ~[?:?]*

```

- 

```
   ... 12 more*

```

Requesting you to please suggest, what i am missing...... and where I am doing wrong.  
Any help would be appreciable.

Thanks,  
Faiz Ahmad

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 21, 2019, 12:08pm UTC](https://discuss.elastic.co/t/watcher-email-configuration/208356/2 "2019-11-21T12:08:55Z")

</div>

So, there are two different exceptions

> Couldn't connect to host, port: [smtp.gmail.com](http://smtp.gmail.com), 587; timeout 120000

This one means, that it could connect to gmail, but was not able to send an email within 2 minutes (which is a long time)

> _Caused by: javax.mail.AuthenticationFailedException: **failed to connect, no password specified?** _

This one means that the user/password could not be successfully authenticated.

I have a hard time spotting the differences between the two setups, maybe you can explain this. Also make sure that after changing a keystore you either restart the node or reload secure settings. And make sure that setting is on every keystore on each node in the cluster (and reloaded), before trying further.

---

<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:** [December 19, 2019, 12:09pm UTC](https://discuss.elastic.co/t/watcher-email-configuration/208356/3 "2019-12-19T12:09:07Z")

</div>

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