# Cannot find default email account as no accounts have been configured

**URL:** <https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 8, 2016, 9:48pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121 "2016-09-08T21:48:13Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![iantayrob](https://avatars.discourse-cdn.com/v4/letter/i/c68b51/32.png) [@iantayrob](https://discuss.elastic.co/u/iantayrob)\
**Post date:** [September 8, 2016, 9:48pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/1 "2016-09-08T21:48:13Z")

</div>

Everytime I execute my Watch I get this error:

```
   {
      "id" : "send_email",
      "type" : "email",
      "status" : "failure",
      "reason" : "IllegalStateException[cannot find default email account as no accounts have been configured]"
    }

```

I have tried many different alternatives but nothing seems to work. As far as I can tell the configuration is correct, but yet I keep getting the same error message.

**Elasticsearch.yml:**

```
xpack.notification.email.account:
      standard_account: 
         profile: standard
         smtp:  
             auth: false
             starttls.enable: false
             host: smtp.mysite.com
             port: 25

```

**The Watcher:**

```
"send_email": {
    "email" : {
      "to" : "user@mysite.com",
        "subject" : "Testing Email Delivery Alerting",
           "body" : "Body content goes here"
  }}
 }
 }

```

The indentation is also correct from what I have read with similar issues...

---

<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 9, 2016, 7:24am UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/2 "2016-09-09T07:24:57Z")

</div>

Hey,

can you please use proper formatting to check the indentation of your configuration? The [this markdown cheat sheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code-and-syntax-highlighting) for code highlighting.

Which Elasticsearch version are you using?

--Alex

---

<div class="post-metadata">

**Author:** ![iantayrob](https://avatars.discourse-cdn.com/v4/letter/i/c68b51/32.png) [@iantayrob](https://discuss.elastic.co/u/iantayrob)\
**Post date:** [September 9, 2016, 4:06pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/3 "2016-09-09T16:06:55Z")

</div>

I have adjusted the formatting to show indentation. We are using ES 5.

---

<div class="post-metadata">

**Author:** ![ave19](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ave19/32/11631_2.png) [@ave19](https://discuss.elastic.co/u/ave19)\
**Post date:** [September 9, 2016, 4:10pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/4 "2016-09-09T16:10:32Z")

</div>

5.0.0-alpha5. (I work with Ian)

---

<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 12, 2016, 9:48am UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/5 "2016-09-12T09:48:39Z")

</div>

Hey,

so I took your configuration, copy pasted it into my alpha5 `elasticsearch.yml` configuration after installing `x-pack` and started up. Saw this in the logs

```auto
[2016-09-12 11:43:01,487][INFO][xpack.notification.email] [bfnTYGv] default account set to [standard_account]

```

This is my `elasticsearch.yaml` configuration

```auto
xpack.security.enabled: false

xpack.notification.email.account:
      standard_account:
         profile: standard
         smtp:
             auth: false
             starttls.enable: false
             host: localhost
             port: 1025

```

Setting up and executing this watch, lead to an email in my test mail server (I used maildev, a neat node.js package you install via `npm install -g maildev`, start via `maildev -v` and then you can open `http://localhost:1080` for a nice web interface to check the emails you get send to `localhost:1025`.

```auto
PUT _xpack/watcher/watch/my-watch
{
  "trigger": {
    "schedule": {
      "interval": "20h"
    }
  },
  "actions": {
    "send_email": {
      "email": {
        "to": "user@mysite.com",
        "subject": "Testing Email Delivery Alerting",
        "body": "Body content goes here"
      }
    }
  }
}

PUT _xpack/watcher/watch/my-watch/_execute

```

So, you config parameters seem to be correct.

- Can you verify the default account is shown on start up?
- Can you show the full configuration of that node? Maybe something gets overwritten? Just run `grep "^[^#]" elasticsearch.yml` - this returns all lines that are not comments.
- Can you try with a configuration like the above (only the bare needed one) and see if that changes anything?

Let's see if we spot somthing

--Alex

---

<div class="post-metadata">

**Author:** ![iantayrob](https://avatars.discourse-cdn.com/v4/letter/i/c68b51/32.png) [@iantayrob](https://discuss.elastic.co/u/iantayrob)\
**Post date:** [September 12, 2016, 6:25pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/6 "2016-09-12T18:25:18Z")

</div>

Everything from your list checks out; however, I am still getting the same issue.

1. According to the logs "default account set to [standard\_account]"
2. An important exception to your example and mine was that I have to have xpack.security.enabled: true
3. I even created a bare components watch similar to your example, and still the same result.
4. Running grep "^[^#]" elasticsearch.yml showed all the configs as expected.

---

<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 13, 2016, 8:02am UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/7 "2016-09-13T08:02:35Z")

</div>

Hey,

can you provide the full/exact configuration file somewhere?

Also, just to be sure, I tested with security enabled and it worked as well.

--Alex

---

<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 13, 2016, 8:13am UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/8 "2016-09-13T08:13:32Z")

</div>

Hey,

also, what happens, when you manually specify the account in the watch, like this?

```auto
      "email": {
        "to": "user@mysite.com",
        "subject": "Testing Email Delivery Alerting",
        "body": "Body content goes here",
        "account" : "standard_account"
      }

```

--Alex

---

<div class="post-metadata">

**Author:** ![iantayrob](https://avatars.discourse-cdn.com/v4/letter/i/c68b51/32.png) [@iantayrob](https://discuss.elastic.co/u/iantayrob)\
**Post date:** [September 13, 2016, 4:02pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/9 "2016-09-13T16:02:28Z")

</div>

Below is the output from running the Watch with the standard\_account included. It would appear that it is having trouble identifying the standard\_account setup. Perhaps there is a disconnect between when the Watch is executed and the file(s) providing default configuration? In particular, the xpack.notification.email.account information and native SMTP in elasticsearch.yml.

```
  {
      "_id" : "my-watch_0-2016-09-13T15:30:14.222Z",
      "watch_record" : {
        "watch_id" : "my-watch",
        "state" : "executed",
        "trigger_event" : {
          "type" : "manual",
          "triggered_time" : "2016-09-13T15:30:14.222Z",
          "manual" : {
            "schedule" : {
              "scheduled_time" : "2016-09-13T15:30:14.222Z"
            }
          }
        },
        "input" : {
          "none" : { }
        },
        "condition" : {
          "always" : { }
        },
        "result" : {
          "execution_time" : "2016-09-13T15:30:14.222Z",
          "execution_duration" : 0,
          "input" : {
            "type" : "none",
            "status" : "success",
            "payload" : { }
          },
          "condition" : {
            "type" : "always",
            "status" : "success",
            "met" : true
          },
          "actions" : [
            {
              "id" : "send_email",
              "type" : "email",
              "status" : "failure",
              "reason" : "IllegalArgumentException[failed to send email with subject [Testing Email Delivery Alerting] via account [standard_account]. account does not exist]"
            }
          ]
        },
        "messages" : []
      }
    }

```

The elasticsearch.yml setup is as follows with the critical information stripped and replaced with dummy information:

```
# ======================== Elasticsearch Configuration =========================
#
# ---------------------------------- Cluster -----------------------------------
#
cluster.name: "ClusterName"
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: "cn#@node#"
node.data: false
node.master: false
node.ingest: true
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.home: ${ES_HOME}
path.conf: ${ES_CONF_DIR}
path.data: ${ES_DATA_DIR}
path.logs: ${LOG_DIR}
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
#
# Elasticsearch performs poorly when the system is swapping the memory.
 # ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: <Native Host Address>
#
# Set a custom port for HTTP:
#
http.port: 9205
transport.tcp.port: 9305
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["<Master Node>:9305"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 4
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# All set to defaults
#
# ---------------------------------- Various -----------------------------------

script.inline: true
script.stored: true
script.engine.groovy.inline.search: on
thread_pool.bulk.queue_size: 1000
# --------------------------------------------------------------------------------
# SMTP Email Server config
# -------------------------------------------------------------------------------

xpack.notification.email.account:
      standard_account:
         profile: standard
         smtp:
             auth: false
             starttls.enable: false
             starttls.required: false
             host: localhost
             port: 25
```

---

<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 15, 2016, 7:54am UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/10 "2016-09-15T07:54:43Z")

</div>

Hey,

are you sure that you put the above configuration on every node and restarted it? Especially on the current master as this is where the watch is being executed?

--Alex

---

<div class="post-metadata">

**Author:** ![iantayrob](https://avatars.discourse-cdn.com/v4/letter/i/c68b51/32.png) [@iantayrob](https://discuss.elastic.co/u/iantayrob)\
**Post date:** [September 15, 2016, 9:12pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/11 "2016-09-15T21:12:50Z")

</div>

Alex,

It appears that some nodes were missing the update in elasticsearch.yml, when I went and applied that exact elasticsearch.yml (Copy/Paste) the results then became as follows:

```
"actions" : [
        {
          "id" : "send_email",
          "type" : "email",
          "status" : "failure",
          "reason" : "NullPointerException[null]"
        }
      ]
    },

```

As a reminder the ES files were appended with:

```
xpack.notification.email.account:
      standard_account:
         profile: standard
         smtp:
             auth: false
             starttls.enable: false
             starttls.required: false
             host: localhost
             port: 25
```

---

<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 16, 2016, 7:19am UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/12 "2016-09-16T07:19:21Z")

</div>

Hey,

are there exceptions in your logs on the master node and can you check the watch history and get the latest entry for that watch?

--Alex

---

<div class="post-metadata">

**Author:** ![iantayrob](https://avatars.discourse-cdn.com/v4/letter/i/c68b51/32.png) [@iantayrob](https://discuss.elastic.co/u/iantayrob)\
**Post date:** [September 16, 2016, 10:20pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/13 "2016-09-16T22:20:32Z")

</div>

So, the Error Message from ES is as follows; I am not aware of any other logs I should be checking so if there is anything else let me know. The Watch History doesn't appear to show anything value either.

> [ERROR][xpack.watcher.actions.email] [ES@MN] failed to execute action [queue/send\_email]  
> java.lang.NullPointerException  
> at org.elasticsearch.xpack.notification.email.Account.send(Account.java:111)  
> at org.elasticsearch.xpack.notification.email.EmailService.send(EmailService.java:70)  
> at org.elasticsearch.xpack.notification.email.EmailService.send(EmailService.java:64)  
> at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:85)  
> at org.elasticsearch.xpack.watcher.actions.ActionWrapper.execute(ActionWrapper.java:109)  
> at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:404)  
> at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:280)  
> at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:476)  
> at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:450)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
> at java.lang.Thread.run(Thread.java:745)

---

<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 26, 2016, 10:50am UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/14 "2016-09-26T10:50:53Z")

</div>

Hey,

did you specify a `from` address in the account configuration or the watch?

Just for testing, can you add a default from?

```auto
xpack.notification.email.account:
  standard_account:
    profile: standard
    email_defaults:
      from: foo@bar.org
    smtp:
      auth: false
      starttls.enable: false
      host: localhost
      port: 1025

```

--Alex

---

<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:42pm UTC](https://discuss.elastic.co/t/cannot-find-default-email-account-as-no-accounts-have-been-configured/60121/15 "2017-07-06T13:42:46Z")

</div>


