# Unable to send email

**URL:** <https://discuss.elastic.co/t/unable-to-send-email/2631>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [June 13, 2015, 9:34pm UTC](https://discuss.elastic.co/t/unable-to-send-email/2631 "2015-06-13T21:34:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhijat](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@abhijat](https://discuss.elastic.co/u/abhijat)\
**Post date:** [June 13, 2015, 9:34pm UTC](https://discuss.elastic.co/t/unable-to-send-email/2631/1 "2015-06-13T21:34:56Z")

</div>

I am trying out one of the watcher examples given here: [https://www.elastic.co/guide/en/watcher/current/watching-marvel-data.html#watching-cpu-usage](https://www.elastic.co/guide/en/watcher/current/watching-marvel-data.html#watching-cpu-usage).

I have configured exchange using the guide: [https://www.elastic.co/guide/en/watcher/current/email-services.html#exchange](https://www.elastic.co/guide/en/watcher/current/email-services.html#exchange).

```
watcher.actions.email.service.account:
    exchange:
        email_defaults:
            from: from@domain.com
        profile: outlook
        smtp:
            auth: true
            starttls.enable: true
            host: email.host.server
            port: 443
            user: username
            password: "password"

```

I get the following error message when the watch triggers an alert:

```
[2015-06-13 14:16:34,871][ERROR][watcher.actions.email] [transport_client_host] failed to execute action [cpu_usage/send_email]
org.elasticsearch.watcher.actions.email.service.EmailException: failed to send email with subject [Watcher Notification - HIGH CPU USAGE] via account [exchange]
    at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:86)
    at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:78)
    at org.elasticsearch.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:64)
    at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:100)
    at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:340)
    at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:392)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.mail.MessagingException: Exception reading response;
  nested exception is:
    java.net.SocketException: Connection reset
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2153)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1912)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
    at javax.mail.Service.connect(Service.java:295)
    at org.elasticsearch.watcher.actions.email.service.Account.send(Account.java:99)
    at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:84)
    ... 8 more
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:196)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89)
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2131)
    ... 13 more

```

Not sure what is missing. One thing that I do notice is that my exchange server host in my mail client (like apple mail or outlook) is actually defined as email.host.server/EWS/Exchange.asmx but when I used this I get the following error:

```
[2015-06-13 14:32:39,173][ERROR][watcher.actions.email] [transport_client_host] failed to execute action [cpu_usage/send_email]
org.elasticsearch.watcher.actions.email.service.EmailException: failed to send email with subject [Watcher Notification - HIGH CPU USAGE] via account [exchange]
    at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:86)
    at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:78)
    at org.elasticsearch.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:64)
    at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:100)
    at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:340)
    at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:392)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.mail.MessagingException: Unknown SMTP host: email.host.server/EWS/Exchange.asmx;
  nested exception is:
    java.net.UnknownHostException: email.host.server/EWS/Exchange.asmx
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1932)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
    at javax.mail.Service.connect(Service.java:295)
    at org.elasticsearch.watcher.actions.email.service.Account.send(Account.java:99)
    at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:84)
    ... 8 more
Caused by: java.net.UnknownHostException: email.host.server/EWS/Exchange.asmx
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
    ... 12 more

```

Any idea what could be missing?

For server urls like email.host.server/EWS/Exchange.asmx should there be another path parameter defined so that one can configure the path separately?

something like:  
smtp.host: email.host.server  
smtp.host.path: /EWS/Exhange.asmx

---

<div class="post-metadata">

**Author:** ![abhijat](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@abhijat](https://discuss.elastic.co/u/abhijat)\
**Post date:** [June 18, 2015, 10:24pm UTC](https://discuss.elastic.co/t/unable-to-send-email/2631/3 "2015-06-18T22:24:40Z")

</div>

Based on this link: [https://scottlinux.com/2014/06/05/check-for-smtp-tls-from-command-line-with-openssl/](https://scottlinux.com/2014/06/05/check-for-smtp-tls-from-command-line-with-openssl/), it appears like my mail server does not support SMPT-TLS. Does it mean that watcher cannot work with my setup?

Any suggestions?

```
CONNECTED(00000003)
didn't found starttls in server response, try anyway...
write:errno=32
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
---
```

---

<div class="post-metadata">

**Author:** ![abhijat](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@abhijat](https://discuss.elastic.co/u/abhijat)\
**Post date:** [June 18, 2015, 10:50pm UTC](https://discuss.elastic.co/t/unable-to-send-email/2631/4 "2015-06-18T22:50:26Z")

</div>

Alright... the following setting works for me:

```
watcher.actions.email.service.account:
    exchange:
        email_defaults:
            from: $your.from.address
        profile: exchange
        smtp:
            auth: false
            starttls.enable: false
            host: $your.mail.server
            port: $your.port
```

---

<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:** [July 6, 2017, 1:49pm UTC](https://discuss.elastic.co/t/unable-to-send-email/2631/5 "2017-07-06T13:49:29Z")

</div>


