Unable to send email

alerting

#1

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.

I have configured exchange using the guide: 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


#3

Based on this link: 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
---

#4

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

(system) #5