Mail binding errors sending mail UnsupportedDataTypeException: text/plaijn; charset=UTF=8

This is on the latest 3.2 released (the first 3.3 snapshot actually but close enough).

I’ve migrated my rules to JSScripting and I think based on what I’ve seen this is only a problem in JSScripting.

When I attempt to send simple text email using the Action I get the following error and no email is sent:

021-12-20 14:42:15.581 [WARN ] [ab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : smtp.gmail.com:587
2021-12-20 14:42:15.581 [WARN ] [ab.binding.mail.internal.SMTPHandler] - javax.mail.MessagingException: IOException while sending message;
  nested exception is:
        javax.activation.UnsupportedDataTypeException: text/plain; charset=UTF-8

When I try to send the same message as HTML:

2021-12-20 14:40:32.423 [WARN ] [ab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : smtp.gmail.com:587
20│2021-12-20 14:40:32.424 [WARN ] [ab.binding.mail.internal.SMTPHandler] - javax.mail.MessagingException: IOException while sending message;
  nested exception is:
        javax.activation.UnsupportedDataTypeException: multipart/alternative; 
        boundary="----=_Part_21_1035614427.1640036431905"

Is anyone experiencing this same error in other languages or is it just JSScripting?

1 Like

Hi @rlkoshak per the other thread, I too am having this issue. I am also using the JavaScript, but it seems to be broken both with the original version of JavaScript (application/javascript) and the new (application/javascript;version=ECMAScript-2021). It was working in 3.1 until I upgraded to 3.2. I have not yet tried DSL or other languages yet.

Here are the details I posted from the other thread:

Anyone else having a problem with their Mail binding after the upgrade? I’m getting:

14:49:46.473 [WARN ] [hab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : redacted.redacted.net:25
14:49:46.476 [WARN ] [hab.binding.mail.internal.SMTPHandler] - javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: text/plain; charset=UTF-8

Thing configuration:

Thing mail:smtp:redacted [ hostname="redacted.redacted.net", sender="redacted@redacted.com" ]

JavaScript code:

actions.get("mail", "mail:smtp:redacted").sendMail("redacted@redacted.com", "Test", "Test")

Actual addresses / IDs redacted. This was working in 3.1 on a manual install at /opt/openhab. It broke after running the upgrade script. I tried a fresh install to see if that made a difference but same problem on a fresh install too.

OK, I’ll remove that part of the title of the thread so it’s clear that this is a more general problem.

I kind of borked my upgrade to JSScripting (it’s all OK now) so IO wasn’t sure if this was a problem or not.

It would be great is someone can report whether or not it’s broken in Rules DSL too. I suspect it’s a universal problem though if it’s broken in both Nashorn and JSScripting.

@rlkoshak I whipped up a DSL rule to test and it’s broken in DSL as well. Same error.

2 Likes

I am on 3.2.0 Release Build. All rules still implemented in Rules DSL. Mail works fine, just tested it with a flood seensor.
Thing is set up in the GUI, using STARTTLS for encryption. The rule code is this:

rule "Reagiere auf Überflutung im Bad"
when
Item Bad_Flutsensor_Flut changed from OFF to ON
then
    if (Logging.state == ON) { logInfo("default","##### Flutsensor meldet Wasser: " + Bad_Flutsensor_Flut.state) }
    postUpdate(Bad_Flutsensor_Flut_Anzeige, ON)
    val message = "Flutsensor meldet Wasser auf dem Boden\n\nManuelles Zurücksetzen des Alarms nicht vergessen!\n\nGreets,\nopenHab"
    val mailActions = getActions("mail","mail:smtp:xxxxxx")
    mailActions.sendMail("redacted@redacted.domain", "ACHTUNG: Wasseralarm", message)
end

OK, so there definitely is something wrong and perhaps it’s only broken in UI rules. In any case I think we have enough info here to file an issue. Thanks!

Issue: [Mail] sendMail and sendHtmlFail errors for UI rules · Issue #11838 · openhab/openhab-addons · GitHub

This is a ClassLoader issue.

Got same exception in a text rule.

Gents, @rlkoshak

I have something here that is probably related, but I can’t fully explain it. My dsl-rules based notification where working fine with OH 3.2 release till this morning.
Today I started trying to build JavaScript based rule turning out in error message described in this thread here.

Since that also my DSL-based rules fail to work
While I have set the debug of javax.mail to Trace I found out that following is written in openhab.log

2021-12-29 22:07:05.279 [WARN ] [javax.mail ] - expected resource not found: /META-INF/javamail.default.address.map

This errors only occured after I started to build new rules. I searched around for the error and it pointed me to similar issues reported here:

Not funny enough. At 18:00 when one of the msg’s should arrive, there was one but coming with an attachement whild should be simple text.

Regards
Stefan

I assume this bug fix will take a while, given the time of year, which puts a stop to my migration to JS.
Is there any workarounds ?

If you set up something like msmtp you can use the executeCommandLine action to send an email like from the command line.

Happy new year 2022!

I also have the issues with the binding. No E-Mail is going out.
I am getting this:

==> /var/log/openhab/openhab.log <==

2022-01-02 13:25:17.041 [WARN ] [rnal.service.RemoteControllerService] - Cannot open remote interface (Connection failed)

2022-01-02 13:27:26.597 [WARN ] [rnal.service.RemoteControllerService] - Cannot open remote interface (Unknown response received for access query)

2022-01-02 17:52:42.571 [INFO ] [rnal.service.RemoteControllerService] - Using Legacy interface

2022-01-02 17:59:39.679 [WARN ] [ab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : smtp.strato.de:465

2022-01-02 17:59:39.682 [WARN ] [ab.binding.mail.internal.SMTPHandler] - java.util.ServiceConfigurationError: javax.mail.Provider: com.sun.mail.imap.IMAPProvider not a subtype

2022-01-03 07:07:00.905 [WARN ] [ab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : smtp.strato.de:465

2022-01-03 07:07:00.930 [WARN ] [ab.binding.mail.internal.SMTPHandler] - java.util.ServiceConfigurationError: javax.mail.Provider: com.sun.mail.imap.IMAPProvider not a subtype

when triggered

==> /var/log/openhab/openhab.log <==
2022-01-03 09:49:22.096 [WARN ] [ab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : smtp.strato.de:465

2022-01-03 09:49:22.107 [WARN ] [ab.binding.mail.internal.SMTPHandler] - javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: multipart/alternative;
boundary="----=_Part_44_9220965.1641199761607"

Getting the same error with new javascript rules as the one in the post by rikoshak at the top. Strangely it seems to be an intermittent problem for me.

Maybe I found the reason for the mail issue. I’ve reported it to @rlkoshak issue on github. It looks like a class loading issue.

The milestone release 3.3.0-M1 doesn’t seem to have fixed this issue?

It wasn’t in the release notes and the issue is still open so no, it’s not fixed yet.

maybe the mail binding is not the problem?

I have the same problem after a jave update and some strange behavior because some rules are sending mails and some not:

As I already said a month ago: this is an issue with classloading. There is nothing a user can do to fix it. It either requires changes in core or in the binding.

or maybe a java engine problem because i didn’t change anything in openhab.

The only thing i did was after a restart of the server:
apt update
apt upgrade
service openhab start