# Unable to send email via Exchange notification

**URL:** <https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 18, 2018, 11:41am UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968 "2018-09-18T11:41:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bab/32/86201_2.png) [@bab](https://discuss.elastic.co/u/bab)\
**Post date:** [September 18, 2018, 11:41am UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968/1 "2018-09-18T11:41:32Z")

</div>

that is my watcher configuration:

"trigger" : {  
"schedule" : { "interval" : "24h" }  
},  
"input" : {  
"search" : {  
"request" : {  
"indices" : ["index\_v2"],  
"body" : {  
"size" : 0,  
"query" : { "match" : { "sev": "w" }  
}  
}  
}  
}  
},  
"condition" : {  
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}  
},  
"transform" : {  
"search" : {  
"request" : {  
"indices" : "index\_v2",  
"body" : {  
"query" : {  
"match" : { "sev": "w" }  
}  
}  
}  
}  
},  
"actions" : {  
"email\_administrator" : {  
"email" : {  
"to" : "extern.brouk\_badr@company.de",  
"subject" : "Encountered {{ctx.payload.hits.total}} errors",  
"body" : "Too many error in the system, see attached data",  
"attachments" : {  
"attached\_data" : {  
"data" : {  
"format" : "json"  
}  
}  
},  
"priority" : "high"  
}  
}  
}  
}

**and this is my elasticsearch.yml configuration:**  
**its work when i use the gmail configuration but if i use the exchange configuration don't work**

Gmail Conf:

#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: [xxxxxxxx@gmail.com](mailto:xxxxxxxx@gmail.com)

# # password: xxxxxxxxxxxx

Exchange Conf:

xpack.notification.email.account:  
exchange\_account:  
profile: outlook  
email\_defaults:  
from: [badr.brouk@company.com](mailto:badr.brouk@company.com)  
smtp:  
auth: true  
starttls.enable: true  
host: [exchange.company.com](http://exchange.company.com) \<-- am not shur, where i fund host for my company exchange or what else  
port: 587  
user: [badr.brouk@company.com](mailto:badr.brouk@company.com)  
password: xxxxxxxx

Any idea what could be missing?

---

<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:** [September 20, 2018, 12:39pm UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968/2 "2018-09-20T12:39:46Z")

</div>

I moved this over to the x-pack category.

This is not really a watcher specific question, but rather a setup question.

First, ask your administrator that you have the correct SMTP servers,ports, users and passwords configured. After you have done that, try running a watch and either check the output of the [execute watch API](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/watcher-api-execute-watch.html) or check the watch history.

Then please share the output of that, so that we can take a look at the error message.

---

<div class="post-metadata">

**Author:** ![bab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bab/32/86201_2.png) [@bab](https://discuss.elastic.co/u/bab)\
**Post date:** [September 21, 2018, 8:09am UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968/3 "2018-09-21T08:09:29Z")

</div>

Thanks @spinscale for your answer:  
i get the SMTP Server Data from my administrator and configured again the elasticsearch.yml, after that checked the output using execute watch API. Its take a long time to execute and at the end become this message :  
{  
"statusCode": 504,  
"error": "Gateway Time-out",  
"message": "Client request timeout"  
}

any idea what is the problem?

---

<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:** [September 21, 2018, 9:31am UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968/4 "2018-09-21T09:31:30Z")

</div>

please call the execute watch API from the command line using a HTTP client like curl and paste the output. The above error message stems from kibana it seems.

---

<div class="post-metadata">

**Author:** ![bab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bab/32/86201_2.png) [@bab](https://discuss.elastic.co/u/bab)\
**Post date:** [September 21, 2018, 6:05pm UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968/5 "2018-09-21T18:05:49Z")

</div>

```
   {
      "id": "email_administrator",
      "type": "email",
      "status": "failure",
      "error": {
        "root_cause": [
          {
            "type": "messaging_exception",
            "reason": "failed to send email with subject [Encountered 93 errors] via account [exchange_account]"
          }
        ],
        "type": "messaging_exception",
        "reason": "failed to send email with subject [Encountered 93 errors] via account [exchange_account]",
        "caused_by": {
          "type": "authentication_failed_exception",
          "reason": "535 5.7.3 Authentication unsuccessful [HE1PR06CA0133.eurprd06.prod.outlook.com]\n"
        }
      }
    }
  ]
},
```

---

<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:** [September 24, 2018, 9:20am UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968/6 "2018-09-24T09:20:29Z")

</div>

This indicates an authentication issue against the mailserver, meaning that the provided credentials are rejected.

---

<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:** [October 22, 2018, 9:20am UTC](https://discuss.elastic.co/t/unable-to-send-email-via-exchange-notification/148968/7 "2018-10-22T09:20:38Z")

</div>

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