# Not able to trigger email from connector

**URL:** <https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [July 14, 2022, 4:38pm UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672 "2022-07-14T16:38:44Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 14, 2022, 4:38pm UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/1 "2022-07-14T16:38:44Z")

</div>

I am configuring a connector to send emails when server is down. for that i have done gmail configuration in elasticsearch.yml  
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: [test.test@somemail.com](mailto:test.test@somemail.com)  
Also executed elasticsearch-keystore add xpack.notification.email.account.gmail\_account.smtp.secure\_password  
to set password.  
The same username and password i have mentioned in connector.  
The same password i have mentioned in connector config.  
Despite of providing valid creds I am getting the issue.

 ![config](https://us1.discourse-cdn.com/elastic/original/3X/4/9/499173537ca41bf435b7d234f585ae4c5a984275.jpeg)  
 ![error](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c709827979e18ffd1a0d1377a40c8b686530c5b4.jpeg)  
 ![consoleError](https://us1.discourse-cdn.com/elastic/original/3X/e/a/ea630db60f3a0cdee1ac3e802443b98c2cbd24a6.jpeg)

---

<div class="post-metadata">

**Author:** ![Patrick\_Mueller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patrick_mueller/32/109425_2.png) [@Patrick\_Mueller](https://discuss.elastic.co/u/Patrick_Mueller)\
**Post date:** [July 14, 2022, 5:16pm UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/2 "2022-07-14T17:16:41Z")

</div>

> [@desai.aditya12](#):
>
> Also executed elasticsearch-keystore add xpack.notification.email.account.gmail\_account.smtp.secure\_password  
> to set password.  
> The same username and password i have mentioned in connector.  
> The same password i have mentioned in connector config.  
> Despite of providing valid creds I am getting the issue.

The `xpack.notification.email.*` settings are for Watcher and specified in the elasticsearch configuration (and keystore), but are not used for Kibana alerting, which it looks like you're using.

There are some notes on the gmail usage here: [Email connector and action | Kibana Guide [8.11] | Elastic](https://www.elastic.co/guide/en/kibana/current/email-action-type.html#gmail)

The other potential problem is that you need to re-enter the userid / password each time you edit the connector. If you make any change to the connector, the credentials need to be re-entered, but I think recent releases of Kibana make that fairly clear (and perhaps prevent saving without them), compared to older releases where it may not have been.

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 14, 2022, 7:08pm UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/4 "2022-07-14T19:08:05Z")

</div>

1. 

In the link provided —\> sending email from gmail there is configuration mentioned. Should It be added to elasticsearch.yml or kibana.yml?

My aim is to trigger mail when the kibana server goes down.  
Is my approach proper or is there any other alternative?

---

<div class="post-metadata">

**Author:** ![hendry.lim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendry.lim/32/71328_2.png) [@hendry.lim](https://discuss.elastic.co/u/hendry.lim)\
**Post date:** [July 15, 2022, 1:35am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/5 "2022-07-15T01:35:29Z")

</div>

You will have to use Elasticsearch [Watcher](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-getting-started.html) if you intend to send an alert if Kibana is down.

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 15, 2022, 4:22am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/6 "2022-07-15T04:22:27Z")

</div>

[Patrick\_Mueller](https://discuss.elastic.co/u/Patrick_Mueller)  
Where shall i add(kibana.yml or elasticsearch.yml) email connector configuration?

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 15, 2022, 6:46am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/8 "2022-07-15T06:46:59Z")

</div>

@hendry.lim  
I have configured a watcher and it's getting triggered but still I am getting error while sending email.  
Please find configuration in elasticsearch.yml  
 ![watcherconfig](https://us1.discourse-cdn.com/elastic/original/3X/e/d/ede7c608f1996b2bc41bbe815cc71d429468fcfe.jpeg)

```auto
{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "heartbeat-*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "query": {
            "bool": {
              "must": {
                "match": {
                  "monitor.status": "down"
                }
              },
              "filter": {
                "range": {
                  "@timestamp": {
                    "from": "now-50s"
                  }
                }
              }
            }
          },
          "aggregations": {
            "by_monitors": {
              "terms": {
                "field": "monitor.id",
                "size": 10,
                "min_doc_count": 1
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gt": 0
      }
    }
  },
  "actions": {
    "email_admin": {
      "email": {
        "profile": "standard",
        "to": [
          "test@testmail.com"
        ],
        "subject": "Server down"
      }
    }
  }
}

```

```auto
[2022-07-15T11:41:01,474][ERROR][o.e.x.w.a.e.ExecutableEmailAction] [node-1] failed to execute action [634b140e-8d33-480d-988a-a06ad4139a1f/email_admin]
javax.mail.MessagingException: failed to send email with subject [Monitor is DOWN: monitorname] via account [gmail_account]
        at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:278) ~[?:?]
        at org.elasticsearch.xpack.watcher.notification.email.EmailService.send(EmailService.java:238) ~[?:?]
        at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:95) ~[?:?]
        at org.elasticsearch.xpack.core.watcher.actions.ActionWrapper.execute(ActionWrapper.java:190) [x-pack-core-8.3.2.jar:?]
        at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:563) [x-pack-watcher-8.3.2.jar:8.3.2]
        at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:342) [x-pack-watcher-8.3.2.jar:8.3.2]
        at org.elasticsearch.xpack.watcher.execution.ExecutionService.lambda$executeAsync$6(ExecutionService.java:440) [x-pack-watcher-8.3.2.jar:8.3.2]
        at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:669) [x-pack-watcher-8.3.2.jar:8.3.2]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:710) [elasticsearch-8.3.2.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
        at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials t21-20020a05620a451500b006af37b005bdsm3136617qkp.128 - gsmtp

```

I have set actual gmail id and password.

---

<div class="post-metadata">

**Author:** ![hendry.lim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendry.lim/32/71328_2.png) [@hendry.lim](https://discuss.elastic.co/u/hendry.lim)\
**Post date:** [July 15, 2022, 7:01am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/9 "2022-07-15T07:01:06Z")

</div>

As the error mentioned:  
`Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted`.

If you have 2FA configured in Gmail, you may need to generate application code/key instead of using username/password to authenticate.

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 15, 2022, 7:14am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/10 "2022-07-15T07:14:56Z")

</div>

@hendry.lim  
I can see than in my gmail setting i have set 2-step verification off.  
Is there any setting to override it in kibana/elasticsearch side?

With respect to the same I am getting below error  
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at  
535 5.7.8 [Check Gmail through other email platforms - Gmail Help](https://support.google.com/mail/?p=BadCredentials) a9-20020a05620a124900b006af08c26774sm3233505qkl.47 - gsmtp

Also 2FA is not enabled.  
How can I make this work?

---

<div class="post-metadata">

**Author:** ![hendry.lim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendry.lim/32/71328_2.png) [@hendry.lim](https://discuss.elastic.co/u/hendry.lim)\
**Post date:** [July 15, 2022, 7:25am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/11 "2022-07-15T07:25:27Z")

</div>

You may need to enable this setting in your Google account:  
`smtp error Error: Invalid login: 535-5.7. 8 Username and Password not accepted. It typically indicates that you did not enable Less Secure Apps on the inbox side of your email address.`

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 15, 2022, 7:54am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/12 "2022-07-15T07:54:37Z")

</div>

@hendry.lim  
[Sign in with App Passwords - Google Account Help](https://support.google.com/mail/?p=InvalidSecondFactor) g14-20020a05620a40ce00b006af3bc9c6bbsm4128401qko.52 - gsmtp

I am not getting any option in gmail side to enable Less Secure Apps. Since that feature is not available

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 15, 2022, 7:56am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/13 "2022-07-15T07:56:35Z")

</div>

Isn't it as simple as creating a watcher and triggering mail. I am only stuck because of  
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at  
535 5.7.8 [Check Gmail through other email platforms - Gmail Help](https://support.google.com/mail/?p=BadCredentials) l67-20020a37bb46000000b006b53fe19c41sm3368597qkf.14 - gsmtp

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 18, 2022, 6:32am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/14 "2022-07-18T06:32:36Z")

</div>

@hendry.lim  
for some reason still I am getting the below error  
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at  
535 5.7.8 [Check Gmail through other email platforms - Gmail Help](https://support.google.com/mail/?p=BadCredentials) d24-20020a05620a167800b006b5cb5d2fa0sm2663987qko.1 - gsmtp

I have disabled 2FA in my gmail acc. also there is not option to enable less secure apps

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 18, 2022, 6:35am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/15 "2022-07-18T06:35:36Z")

</div>

@hendry.lim  
Is there any other way to configure yahoo mail id in elasticsearch?

---

<div class="post-metadata">

**Author:** ![hendry.lim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendry.lim/32/71328_2.png) [@hendry.lim](https://discuss.elastic.co/u/hendry.lim)\
**Post date:** [July 18, 2022, 7:10am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/16 "2022-07-18T07:10:41Z")

</div>

I would suggest to create an app password with Gmail.

You can configure multiple email accounts under `xpack.notification.email.*`.

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 18, 2022, 10:26am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/19 "2022-07-18T10:26:36Z")

</div>

@hendry.lim  
It worked for gmail but for outlook it's failing,  
getting below error:

Caused by: javax.mail.AuthenticationFailedException: 535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [[CH2PR03CA0027.namprd03.prod.outlook.com](http://CH2PR03CA0027.namprd03.prod.outlook.com)]

configuration:

```auto
xpack.notification.email.account:
    outlook_account:
        profile: outlook
        smtp:
            auth: true
            starttls.enable: true
            host: smtp-mail.outlook.com
            port: 587
            user: test@testmail.com

```

Any solution for this.  
I have set proper password too

---

<div class="post-metadata">

**Author:** ![hendry.lim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendry.lim/32/71328_2.png) [@hendry.lim](https://discuss.elastic.co/u/hendry.lim)\
**Post date:** [July 18, 2022, 11:26pm UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/21 "2022-07-18T23:26:58Z")

</div>

All the errors you were encountering had nothing to do with Elasticsearch. I would suggest you to resolve the errors by testing the access with an email client. Once that's working, use the same configuration in Elasticsearch.

---

<div class="post-metadata">

**Author:** ![desai.aditya12](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@desai.aditya12](https://discuss.elastic.co/u/desai.aditya12)\
**Post date:** [July 28, 2022, 9:35am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/22 "2022-07-28T09:35:55Z")

</div>

Hi @hendry.lim  
I am trying to use elastalert with heartbeat and elasticsearch, to trigger email when site goes down.  
Please find below configuration file for example\_frequency.yaml

```auto
# Alert when the rate of events exceeds a threshold

# (Optional)
# Elasticsearch host
# es_host: elasticsearch.example.com

# (Optional)
# Elasticsearch port
# es_port: 14900

# (OptionaL) Connect with SSL to Elasticsearch
#use_ssl: True

# (Optional) basic-auth username and password for Elasticsearch
#es_username: someusername
#es_password: somepassword

# (Required)
# Rule name, must be unique
name: Heartbeat trigger

# (Required)
# Type of alert.
# the frequency rule type alerts when num_events events occur with timeframe time
type: frequency

# (Required)
# Index to search, wildcard supported
index: heartbeat-*

# (Required, frequency specific)
# Alert when this many documents matching the query occur within a timeframe
num_events: 1

# (Required, frequency specific)
# num_events must occur within this amount of time to trigger an alert
timeframe:
  seconds: 4

# (Required)
# A list of Elasticsearch filters used for find events
# These filters are joined with AND and nested in a filtered query
# For more info: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html
filter:
- term:
    monitor.status: "up"

# (Required)
# The alert is use when a match is found
alert:
- "email"

# (required, email specific)
# a list of email addresses to send alerts to
email:
- "some mail id"

```

While running python -m elastalert.elastalert --verbose --rule example\_frequency.yaml  
I am getting below error:

 ![elastalerterror](https://us1.discourse-cdn.com/elastic/original/3X/0/7/0733919f2cdc4887c48b3a919db474b773d01758.jpeg)

Is there any configuration which i am missing?

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [July 28, 2022, 10:13am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/23 "2022-07-28T10:13:47Z")

</div>

Elastalert is not an Elastic product, it is an [open-source project started by Yelp](https://github.com/Yelp/elastalert). Please seek help for that product elsewhere or use [Kibana Alerting](https://www.elastic.co/guide/en/kibana/current/alerting-getting-started.html) (which we do make). We'd be happy to help you with Kibana Alerting.

---

<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:** [August 25, 2022, 10:14am UTC](https://discuss.elastic.co/t/not-able-to-trigger-email-from-connector/309672/24 "2022-08-25T10:14:41Z")

</div>

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