# X-pack Watcher service : not able to send the mail

**URL:** <https://discuss.elastic.co/t/x-pack-watcher-service-not-able-to-send-the-mail/89731>\
**Category:** Elasticsearch\
**Created:** [June 16, 2017, 2:15pm UTC](https://discuss.elastic.co/t/x-pack-watcher-service-not-able-to-send-the-mail/89731 "2017-06-16T14:15:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiranilla](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kiranilla](https://discuss.elastic.co/u/kiranilla)\
**Post date:** [June 16, 2017, 2:15pm UTC](https://discuss.elastic.co/t/x-pack-watcher-service-not-able-to-send-the-mail/89731/1 "2017-06-16T14:15:36Z")

</div>

For mail configuration i have added the following piece of code in elasticsearch.yml  
at the end of the file:  
\> xpack.watcher.enabled: true

> ```
> xpack.notification.email.account:
> gmail_account:
> profile: gmail
> smtp:
> auth: true
> starttls.enable: true
> host: smtp.gmail.com
> port: 587
> user: "kiranmadh"
> password: " ************"
> 
> ```

I have modified the following code in management -\> watcher -\>

> "email\_administrator": {  
> "email": {  
> "profile": "standard",  
> "attachments": {  
> "attached\_data": {  
> "data": {  
> "format": "json"  
> }  
> }  
> },  
> "priority": "high",  
> "to": [  
> "[kiran.kumar.illa@accenture.com](mailto:kiran.kumar.illa@accenture.com)"  
> ],  
> "subject": "Encountered {{ctx.payload.hits.total}} errors",  
> "body": {  
> "text": "Too many error in the system, see attached data"  
> }  
> }
> 
> ![](https://us1.discourse-cdn.com/elastic/original/3X/3/1/31c74e0ad9a90b9f4a9baf59d59c42e8abfa7f4f.JPG)

Logstash is also in running state...

I have restarted the ES but i have encountered with the following error and not able to receive any mail:

```
2017-06-16T19:30:39,932][ERROR][o.e.x.w.a.e.ExecutableEmailAction] [2HZAhP9] failed to execute action [jira/email_administrator]
javax.mail.MessagingException: failed to send email with subject [Encountered 38 errors] via account [gmail_account]
        at org.elasticsearch.xpack.notification.email.EmailService.send(EmailService.java:66) ~[x-pack-5.4.0.jar:5.4.0]
        at org.elasticsearch.xpack.notification.email.EmailService.send(EmailService.java:58) ~[x-pack-5.4.0.jar:5.4.0]
        at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:86) ~[x-pack-5.4.0.jar:5.4.0]
        at org.elasticsearch.xpack.watcher.actions.ActionWrapper.execute(ActionWrapper.java:160) [x-pack-5.4.0.jar:5.4.0]

```

Please find the attached screen shot for reference.

 ![](https://us1.discourse-cdn.com/elastic/original/3X/1/b/1bde97c6ccfdf6a64f64840e45846081df54b0f2.JPG)

**Could you please help me on resolving this issue..**  
**Thanks in advance**

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [June 19, 2017, 2:10pm UTC](https://discuss.elastic.co/t/x-pack-watcher-service-not-able-to-send-the-mail/89731/2 "2017-06-19T14:10:27Z")

</div>

Hi Kiran,

What I see in the middle of your screenshot is

`AuthenticationFailedException` with a link after that like `<https://accounts.google.com/signin.... >`

`Please log in via your web browser and then try again`

`Learn more at`  
`https://support.google.com/mail/answer...`

So the problem has to do with authentication of the gmail account configured in your elasticsearch.yml file. That's the account that is being used to send the email but it's failing authentication. If you have 2-factor authentication configured on that gmail account set up that could make this difficult.

You could start by visiting the link logged right after the AuthenticationFailedException and see if that resolves the issue for you.

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![kiranilla](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kiranilla](https://discuss.elastic.co/u/kiranilla)\
**Post date:** [June 21, 2017, 6:20am UTC](https://discuss.elastic.co/t/x-pack-watcher-service-not-able-to-send-the-mail/89731/3 "2017-06-21T06:20:39Z")

</div>

**Thanks Lee for your help.....** i got it.. there is missing configuration from gmail account as below  
"If you get an authentication error that indicates that you need to continue the sign-in process from a web browser when Watcher attempts to send email, you need to configure Gmail to Allow Less Secure Apps to access your account."

and one more change in the elasticsearch.yml file :  
i should not provide the crendentials with in "" (double cotes)  
It should be as shown below:  
smtp:  
auth: true  
starttls.enable: true  
host: [smtp.gmail.com](http://smtp.gmail.com)  
port: 587  
user: [kiranma@gmil.com](mailto:kiranma@gmil.com)  
password: \*\*\*\*\*\*\*\*\*\*\*\*

I have followed the above step and i am able to send the mail..

---

<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 19, 2017, 6:21am UTC](https://discuss.elastic.co/t/x-pack-watcher-service-not-able-to-send-the-mail/89731/4 "2017-07-19T06:21:30Z")

</div>

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