# Cant able to send mail from watcher

**URL:** <https://discuss.elastic.co/t/cant-able-to-send-mail-from-watcher/229131>\
**Category:** Elasticsearch\
**Created:** [April 21, 2020, 8:56pm UTC](https://discuss.elastic.co/t/cant-able-to-send-mail-from-watcher/229131 "2020-04-21T20:56:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakeshraagu2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rakeshraagu2/32/66283_2.png) [@rakeshraagu2](https://discuss.elastic.co/u/rakeshraagu2)\
**Post date:** [April 21, 2020, 8:56pm UTC](https://discuss.elastic.co/t/cant-able-to-send-mail-from-watcher/229131/1 "2020-04-21T20:56:41Z")

</div>

Hi All,

Iam trying to send alert mail from watcher but failed to send mail.  
Iam using a gmail account.

This is the error message i gets from cluster log

[2020-04-22T02:20:37,420][ERROR][o.e.x.w.a.e.ExecutableEmailAction] [elk-master] failed to execute action [_inlined_/email\_1]  
javax.mail.MessagingException: failed to send email with subject [Watch [test] has exceeded the threshold] via account [gmail\_account]  
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.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:534) [x-pack-watcher-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:320) [x-pack-watcher-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:159) [x-pack-watcher-7.6.2.jar:7.6.2]  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.6.2.jar:7.6.2]  
at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:627) [x-pack-watcher-7.6.2.jar:7.6.2]  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:633) [elasticsearch-7.6.2.jar:7.6.2]  
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:830) [?:?]  
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:722) ~[?:?]  
at javax.mail.Service.connect(Service.java:342) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.Account.lambda$executeConnect$2(Account.java:161) ~[?:?]  
at java.security.AccessController.doPrivileged(AccessController.java:554) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.Account.executeConnect(Account.java:160) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.Account.send(Account.java:119) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:169) ~[?:?]  
... 12 more  
Caused by: java.net.ConnectException: Connection refused  
at sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]  
at sun.nio.ch.Net.pollConnectNow(Net.java:579) ~[?:?]  
at sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:549) ~[?:?]  
at sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) ~[?:?]  
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:339) ~[?:?]  
at java.net.Socket.connect(Socket.java:603) ~[?:?]  
at com.sun.mail.util.WriteTimeoutSocket.connect(WriteTimeoutSocket.java:91) ~[?:?]  
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:333) ~[?:?]  
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:214) ~[?:?]  
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160) ~[?:?]  
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722) ~[?:?]  
at javax.mail.Service.connect(Service.java:342) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.Account.lambda$executeConnect$2(Account.java:161) ~[?:?]  
at java.security.AccessController.doPrivileged(AccessController.java:554) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.Account.executeConnect(Account.java:160) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.Account.send(Account.java:119) ~[?:?]  
at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:169) ~[?:?]  
... 12 more

configuration file for elasticsearch

xpack.notification.email.account:  
gmail\_account:  
profile: gmail  
email\_defaults:  
from: [raagurakesh765@gmail.com](mailto:raagurakesh765@gmail.com)  
smtp:  
auth: true  
starttls.enable: true  
host: [smtp.gmail.com](http://smtp.gmail.com)  
port: 587  
user: gmail-id

password key stored using,

sudo ./elasticsearch-keystore add xpack.notification.email.account.my-gmail-id.smtp.secure\_password

pls help. Is there anything missing from the configuration?....

Thanks in advance.

---

<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:** [May 19, 2020, 8:56pm UTC](https://discuss.elastic.co/t/cant-able-to-send-mail-from-watcher/229131/2 "2020-05-19T20:56:50Z")

</div>

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