# Watcher email messages are not UTF-8 encoded

**URL:** <https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905>\
**Category:** Elasticsearch\
**Created:** [September 30, 2016, 9:07am UTC](https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905 "2016-09-30T09:07:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [September 30, 2016, 9:07am UTC](https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905/1 "2016-09-30T09:07:47Z")

</div>

I have a environment as below .

```
[root@Test-Env mail]# rpm -qa | grep elasticsearch
elasticsearch-5.0.0_beta1-1.noarch
[root@Test-Env mail]# /usr/share/elasticsearch/bin/elasticsearch-plugin list
x-pack@5.0.0-beta1

```

However, I want to use UTF-8 charcters in email subject and body but Watcher is not encoding with UTF-8.

Thus the strings gets corrupted.

Message-ID: test\_8-2016-09-30T08:40:35.492Z  
Subject: **=?UTF-8?B?55Ww5bi444OX44Ot44K744K55Lu25pWwIDU=?=**  
MIME-Version: 1.0  
Content-Type: multipart/mixed;  
boundary="----=\_Part\_4\_284485771.1475224835571"  
X-Priority: 2  
From: elasticsearch@BS-POC-Test-Env.localdomain

------=\_Part\_4\_284485771.1475224835571  
Content-Type: multipart/related;  
boundary="----=\_Part\_5\_1375459366.1475224835571"

------=\_Part\_5\_1375459366.1475224835571  
Content-Type: multipart/alternative;  
boundary="----=\_Part\_6\_1756655719.1475224835571"

------=\_Part\_6\_1756655719.1475224835571  
Content-Type: text/plain; charset=UTF-8  
Content-Transfer-Encoding: base64

**55Ww5bi444OX44Ot44K744K544Gu5LiA6Kan**

Is there a way to encode the messages in subject and body with UTF-8?  
Specifically, I am using Japanese characters.

---

<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:** [October 10, 2016, 7:41pm UTC](https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905/2 "2016-10-10T19:41:08Z")

</div>

Hi,

If we focus first on the email subject. Can you do a get on that watch after you load it and confirm that your subject was stored correctly in Elasticsearch? I'm just trying to understand if the problem is in the creation of the watch or when it executes and sends the email.

Thanks,  
Lee

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [October 12, 2016, 2:03am UTC](https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905/3 "2016-10-12T02:03:56Z")

</div>

Ok.

I now use the elasticsearch beta .

```
[root@BS-POC-Test-Env y-watanabe]# rpm -qa | grep elasticsearch
elasticsearch-5.0.0_beta1-1.noarch

```

Below is the definition I have inserted with PUT request.  
Subject is in **Japanese**.

```
PUT _xpack/watcher/watch/test_20161012
{
  "metadata" : { 
    "color" : "red"
  },
  "trigger" : { 
    "schedule" : {
      "interval" : "5m"
    }
  },
  "input" : { 
    "search" : {
      "request" : {
        "indices" : "syslog",
        "body" : {
          "query" : {
            "bool" : {
              "must" : [
                {"match" : { "program.keyword" : "kibana" }},
                {"range" : { "@timestamp" : {"gte" : "now-5m", "lte" : "now" } } }
              ]
            }
          }
        }
      }
    }
  },
  "condition" : { 
    "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
  },
  "actions" : { 
    "email_administrator" : {
      "email" : {
        "to" : "root@localhost.localdomain",
        "subject" : "あいうえお {{ctx.payload.hits.total}}",
        "body" : "Error message",
        "attachments" : {
          "attached_data" : {
            "data" : {
              "format" : "json"
            }
          }
        },
        "priority" : "high"
      }
    }
  }
}

```

I have done a get against _test-20161012_ and it looks like the terms are stored properly.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/c/c4f5e9f300a3379215ed538f83ab572da1d6026e.PNG)

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [October 12, 2016, 2:04am UTC](https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905/4 "2016-10-12T02:04:35Z")

</div>

As a execution result , mail subject is corrupted.

```
From elasticsearch@BS-POC-Test-Env.localdomain Wed Oct 12 11:02:41 2016
Return-Path: <elasticsearch@BS-POC-Test-Env.localdomain>
X-Original-To: root@localhost.localdomain
Delivered-To: root@localhost.localdomain
Received: from 10.4.0.4 (localhost [127.0.0.1])
        by BS-POC-Test-Env.localdomain (Postfix) with ESMTP id 1039241D2ABF
        for <root@localhost.localdomain>; Wed, 12 Oct 2016 11:02:41 +0900 (JST)
Date: Wed, 12 Oct 2016 11:02:40 +0900 (JST)
To: root@localhost.localdomain
Message-ID: test_20161012_0-2016-10-12T02:02:39.140Z
Subject: =?UTF-8?B?44GC44GE44GG44GI44GKIDMx?=
MIME-Version: 1.0
Content-Type: multipart/mixed;
        boundary="----=_Part_13148_1469291581.1476237761031"

```

Just to be sure, I have checked that my server's LANG setting is UTF-8.

```
[root@BS-POC-Test-Env mail]# env | grep LANG
LANG=en_US.UTF-8
```

---

<div class="post-metadata">

**Author:** ![YuWatanabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuwatanabe/32/13259_2.png) [@YuWatanabe](https://discuss.elastic.co/u/YuWatanabe)\
**Post date:** [November 7, 2016, 11:00am UTC](https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905/5 "2016-11-07T11:00:33Z")

</div>

Any update with this issue?

---

<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:40pm UTC](https://discuss.elastic.co/t/watcher-email-messages-are-not-utf-8-encoded/61905/6 "2017-07-06T13:40:09Z")

</div>


