# Send mail failed with "UnsupportedDataTypeException"

**URL:** <https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [October 28, 2015, 11:44am UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144 "2015-10-28T11:44:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 28, 2015, 11:44am UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/1 "2015-10-28T11:44:43Z")

</div>

ES log:

```
[2015-10-28 19:01:01,161][ERROR][watcher.actions.email] [crawler_service_001] failed to execute action [error-watch/alert_email]
javax.mail.MessagingException: failed to send email with subject [some error] via account [u51_account];
  nested exception is:
	javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_24_355222995.1446030060989"
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:85)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:77)
	at org.elasticsearch.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:67)
	at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:106)
	at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:381)
	at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:273)
	at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:419)
	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)
Caused by: javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_24_355222995.1446030060989"
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1245)
	at org.elasticsearch.watcher.actions.email.service.Account.send(Account.java:109)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:83)
	... 9 more
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_24_355222995.1446030060989"
	at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:896)
	at javax.activation.DataHandler.writeTo(DataHandler.java:317)
	at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1627)
	at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1849)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1196)
	... 11 more

```

The code to build email action:

```
EmailTemplate.Builder emailBuilder = EmailTemplate.builder();
emailBuilder.to(receivers);
emailBuilder.subject(subject);
String bodyTemplate = ResourceUtils.readResourceToString("error-message-email-body-template.html");
emailBuilder.htmlBody(bodyTemplate);
EmailAction.Builder emailActionBuilder = EmailAction.builder(emailBuilder.build());
emailActionBuilder.setAttachPayload(DataAttachment.YAML);
return emailActionBuilder;

```

Both ES and watcher are `2.0.0-rc1`.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 28, 2015, 11:48pm UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/2 "2015-10-28T23:48:41Z")

</div>

We've just released the GAs for ES and Watcher 2.0, have you tried with those?

---

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 29, 2015, 8:27am UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/3 "2015-10-29T08:27:15Z")

</div>

Thanks your advice but I upgrade both elasticsearch and watcher to 2.0.0（without `rc1`, sure）, it still gives:

```
[2015-10-29 16:25:02,004][ERROR][watcher.actions.email] [crawler_service_001] failed to execute action [error-watch/alert_email]
javax.mail.MessagingException: failed to send email with subject [errors encountered!] via account [u51_account];
  nested exception is:
	javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_4_1547992646.1446107101838"
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:85)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:77)
	at org.elasticsearch.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:67)
	at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:106)
	at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:381)
	at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:274)
	at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:419)
	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)
Caused by: javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_4_1547992646.1446107101838"
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1245)
	at org.elasticsearch.watcher.actions.email.service.Account.send(Account.java:109)
	at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:83)
	... 9 more
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; 
	boundary="----=_Part_4_1547992646.1446107101838"
	at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:896)
	at javax.activation.DataHandler.writeTo(DataHandler.java:317)
	at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1627)
	at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1849)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1196)
	... 11 more

```

@warkolm @spinscale

---

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 30, 2015, 8:19am UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/4 "2015-10-30T08:19:12Z")

</div>

I find that error always occurs despite of which type(JSON or YAML) of attachment of the mail. Even no attachment still encountered that error.

I google about that, some guys say that the cause of that problem is the version of java mail library. But as you know, Watcher is not a open source plugin, so it's hard for me to figure out what goes wrong in mail module of Watcher.

I Upgraded Watcher and ES to `2.0.0-rc1`(then `2.0.0` after GA released) on Monday , but just couldn't send a mail successfully up to now, this Friday. I'm under a lot of stress because a team waiting this feature for a week. I can't roll back ES to 1.7 because another team wants Kibana `4.2.0`(custom name for filter, a great feature) badly.

Really looking-forward a reply from you official guys.

@spinscale

---

<div class="post-metadata">

**Author:** ![kurtcoke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kurtcoke/32/3888_2.png) [@kurtcoke](https://discuss.elastic.co/u/kurtcoke)\
**Post date:** [November 2, 2015, 7:43am UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/5 "2015-11-02T07:43:59Z")

</div>

Look at what they suggested in this thread: [UnsupportedDataTypeException when trying to send email](https://discuss.elastic.co/t/unsupporteddatatypeexception-when-trying-to-send-email/28634/6)

This worked for me on the latest watcher, and ES 2.0.0 Stable:

```
$ cd /usr/share/elasticsearch/plugins/watcher/
    $ sudo mv activation-1.1.1.jar ../../lib/
    $ sudo mv javax.mail-1.5.3.jar ../../lib/
    $ sudo service elasticsearch restart
```

---

<div class="post-metadata">

**Author:** ![mcku](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mcku/32/33775_2.png) [@mcku](https://discuss.elastic.co/u/mcku)\
**Post date:** [November 20, 2015, 3:08pm UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/6 "2015-11-20T15:08:28Z")

</div>

@kurtcoke Thanks for the concise workaround. I have faced this on a Windows environment ES 2.0 GA, and the workaround was very useful.

---

<div class="post-metadata">

**Author:** ![demuxer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/demuxer/32/6623_2.png) [@demuxer](https://discuss.elastic.co/u/demuxer)\
**Post date:** [December 14, 2015, 10:07pm UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/7 "2015-12-14T22:07:40Z")

</div>

simply AWESOME! thanks a lot

---

<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:** [December 21, 2015, 10:36am UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/8 "2015-12-21T10:36:36Z")

</div>

Hey,

just a quick heads up. This is fixed in Elasticsearch 2.0.2 and 2.1.1 and does not require any workarounds any more.

--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:47pm UTC](https://discuss.elastic.co/t/send-mail-failed-with-unsupporteddatatypeexception/33144/9 "2017-07-06T13:47:43Z")

</div>


