# Error in sending email : \[WATCHER\]

**URL:** <https://discuss.elastic.co/t/error-in-sending-email-watcher/48688>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [April 28, 2016, 2:26pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688 "2016-04-28T14:26:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviral\_srivastava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviral_srivastava/32/98018_2.png) [@aviral\_srivastava](https://discuss.elastic.co/u/aviral_srivastava)\
**Post date:** [April 28, 2016, 2:26pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/1 "2016-04-28T14:26:18Z")

</div>

"actions": [  
{  
"id": "email\_admin",  
"type": "email",  
"status": "failure",  
"reason": "MessagingException[failed to send email with subject [Watcher Executed] via account [S-IWEBTRANSLATORTO]]; nested: MessagingException[Could not convert socket to TLS]; nested: SSLHandshakeException[sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target]; nested: ValidatorException[PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target]; nested: SunCertPathBuilderException[unable to find valid certification path to requested target]; "  
}  
]  
Can anybody help

---

<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:** [April 28, 2016, 3:07pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/2 "2016-04-28T15:07:25Z")

</div>

Hey,

there seems to be an issue connecting via TLS to the SMTP server.

The `SunCertPathBuilderException` above indicates that a certificate was returned during the handshake that is not trusted. This message is seen on the client side of the connection. The `SSLException` above is seen on the server side of the connection.

You need to configure [https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html](https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html) - which can be configured in watcher [email settings](https://www.elastic.co/guide/en/watcher/current/email-services.html)

Hope this helps

--Alex

---

<div class="post-metadata">

**Author:** ![aviral\_srivastava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviral_srivastava/32/98018_2.png) [@aviral\_srivastava](https://discuss.elastic.co/u/aviral_srivastava)\
**Post date:** [April 29, 2016, 8:13am UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/3 "2016-04-29T08:13:58Z")

</div>

Hi spinscale,  
thanks for your response.  
**MY WATCHER CONFIGURATION IS THIS:-**  
{  
"trigger" : {  
"schedule" : { "interval" : "10s" }  
},  
"input" : {  
"search" : {  
"request" : {  
"indices" : ["smartlog"],  
"body" : {  
"query" : {  
"match" : { "logLevel": "ERROR" }  
}  
}  
}  
}  
},  
"condition" : {  
"compare" : {  
"ctx.payload.hits.total" : { "gt" : 50 }  
}  
},  
"actions" : {  
"email\_admin" : {  
"email": {  
"to": "aviral.srivastava@company.com",  
"subject": "Watcher Executed",  
"body": "Congrats, you have successfully configured watcher to send email"  
}  
}  
}  
}  
**MY elasticsearch.yml CONFIGURATION :-**  
watcher.actions.email.service.account:  
exchange\_account:  
profile: outlook  
email\_defaults:  
from: [webtranslatortool.in@company.com](mailto:webtranslatortool.in@company.com)  
smtp:  
auth: true  
starttls.enable: true  
host: [ismtp.corp.company.com](http://ismtp.corp.company.com)  
port: 25  
user: abcde  
password: abcde  
ssl.trust: [ismtp.corp.company.com](http://ismtp.corp.company.com)  
**IN MY WATCHER HISTORY I GET BELOW ERROR :-**  
"actions": [  
{  
"id": "email\_admin",  
"type": "email",  
"status": "failure",  
"reason": "MessagingException[failed to send email with subject [Watcher Executed] via account [exchange\_account]]; nested: AuthenticationFailedException[No authentication mechanisms supported by both server and client]; "  
}  
]

---

<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:** [April 29, 2016, 11:24am UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/4 "2016-04-29T11:24:15Z")

</div>

Hey,

your second exception is different than the first. See the watch history

```auto
No authentication mechanisms supported by both server and client

```

This means that the server and the client could not negotiate an auth mechanism. What kind of server is that? Maybe there is a mail server configuration error, that it does not support user based auth?

Checking the log files of your mail server might help a lot here.

--Alex

---

<div class="post-metadata">

**Author:** ![aviral\_srivastava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviral_srivastava/32/98018_2.png) [@aviral\_srivastava](https://discuss.elastic.co/u/aviral_srivastava)\
**Post date:** [April 29, 2016, 1:36pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/5 "2016-04-29T13:36:07Z")

</div>

Dear Alex,

We are in a corporate environment. There is a corporate exchange server.  
So, I do not have access to the server logs here.

I tried to connect to our corporate exchange server using TELNET from my system.  
I was able to connect. and also send email from [webtranslatortool.in@company.com](mailto:webtranslatortool.in@company.com) to [aviral.srivastava@company.com](mailto:aviral.srivastava@company.com) ..  
NOTE:- These are the same emails as I specified in the elasticsearch.yml and watcher configuration.

It seems I have issue in the elasticsearch.yml configuration.

---

<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:** [April 29, 2016, 1:59pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/6 "2016-04-29T13:59:23Z")

</div>

Hey,

please google for that particular error message. Looks to me as if smtp auth is not supported by exchange out of the box and requires configuration. Can you tell me how your current authentication works with your exchange server, so one can see if java mail supports it?

Also setting up a small java program usign javamail would allow to rule out java as a problem source.

--Alex

---

<div class="post-metadata">

**Author:** ![aviral\_srivastava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviral_srivastava/32/98018_2.png) [@aviral\_srivastava](https://discuss.elastic.co/u/aviral_srivastava)\
**Post date:** [April 29, 2016, 2:29pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/7 "2016-04-29T14:29:43Z")

</div>

Thanks Alex for your suggestion,

I wrote a smail java program using javamail and I was able to send email.  
package com.mail;

import java.util._;  
import javax.mail._;  
import javax.mail.internet._;  
import javax.activation._;

public class SendEmail  
{  
public static void main(String [] args)  
{  
// Recipient's email ID needs to be mentioned.  
String to = "aviral.srivastava@company.com";

```
  // Sender's email ID needs to be mentioned
  String from = "webtranslatortool.in@company.com";

  // Assuming you are sending email from localhost
  String host = "ismtp.corp.company.com";

  // Get system properties
  Properties properties = System.getProperties();

  // Setup mail server
  properties.setProperty("mail.smtp.host", host);

  // Get the default Session object.
  Session session = Session.getDefaultInstance(properties);

  try{
     // Create a default MimeMessage object.
     MimeMessage message = new MimeMessage(session);

     // Set From: header field of the header.
     message.setFrom(new InternetAddress(from));

     // Set To: header field of the header.
     message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

     // Set Subject: header field
     message.setSubject("This is the Subject Line!");

     // Now set the actual message
     message.setText("This is actual message");

     // Send message
     Transport.send(message);
     System.out.println("Sent message successfully....");
  }catch (MessagingException mex) {
     mex.printStackTrace();
  }

```

}  
}

It seems authentication is not required and can you help me what should i configure in elastisearch.yml file

---

<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:** [April 29, 2016, 3:08pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/8 "2016-04-29T15:08:00Z")

</div>

recheck and adapt your watcher configuration, it is vastly different using SMTP auth and TLS, you should remove those settings.

---

<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:45pm UTC](https://discuss.elastic.co/t/error-in-sending-email-watcher/48688/9 "2017-07-06T13:45:50Z")

</div>


