Closed rkoshak closed 2 years ago
This issue has been mentioned on openHAB Community. There might be relevant details there:
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/openhab-3-2-release-discussion/130327/30
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/mail-binding-unsupporteddatatypeexception-error/130530/3
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/javascript-email-ioexemption/130910/2
Hello @jpg0 and @digitaldan,
this issue is marked as mail binding issue. But I was able to fix the by just removing the line from the jsscripting binding. After that I was able to send mails again.
I think it hase something to do with the change for another class loading issues https://github.com/openhab/openhab-addons/issues/11222
This issue has been mentioned on openHAB Community. There might be relevant details there:
I'm having this issue with the Groovy scripting. So it seems like it's not specific for the JS scripting.
OH3.2: I installed the Mail binding because i need to get a reliable way to be alerted to an issue. So I was going to send email-text to my phone. However, I get this problem. Two questions: 1) as this seems like the cleanest solution, is there an ETA on a fix? 2) If no fix coming soon, is there a work around, another option, etc. that can be utilized either permanently or temporarily?
is there a work around, another option, etc. that can be utilized either permanently or temporarily?
I am sure there is better or more elegant solutions. But since I did not want to wait with migrating my rules to JS, I have just built myself a quick and dirty workaround by:
That way, I can send emails from any JS rule by using that string item. Once this bug is fixed, I can then just quickly replace the sendCommand in the JS rule with the respective mailAction command
Hi Kstuken, can you post your creation?
is there a work around, another option, etc. that can be utilized either permanently or temporarily?
I am sure there is better or more elegant solutions. But since I did not want to wait with migrating my rules to JS, I have just built myself a quick and dirty workaround by:
- creating a string item
- in the JS rule, not being able to send the email from there, sendCommand() a JSON containing the relevant email info (recipient, subject, message) to the string item
- creating a DSL rule that is triggered by the command to string item, parses the JSON, and then send the email (and then clears the string item via postUpdate())
That way, I can send emails from any JS rule by using that string item. Once this bug is fixed, I can then just quickly replace the sendCommand in the JS rule with the respective mailAction command
Hi Kstuken, can you post your creation?
@kstuken I'll give it a try.
I agree with @martychristensen, it would be nice to see your "creation" for reference.
@kstuken did I do something wrong or stumble across another issue with javascript in 3.2? In my JS rule, I issue the following command (per documentation)
items.getItem("WolfeDen_Mail").sendCommand("redacted")
However, I get:
TypeError: items.getItem is not a function
??
It seems like javascript has to many issues. I created a dsl rule to replace my js rule and all is fine.
UPDATE: it worked ONCE and then stopped. Now I'm getting:
javax.activation.UnsupportedDataTypeException: text/plain; charset=UTF-8
so I'm back to square one with the Mail binding.
@kstaniek can you post how your DSL script is working as I can't get anything related to mail work.
Sure, if that helps:
Here's the item:
String Mailtransporter "JSON String with values for mailer"
Here's the command sent in JS script
const mailObject = {
to: "some@email.com",
subject: "subject line",
message: "Message body goes here...",
};
items.getItem("Mailtransporter").postUpdate(JSON.stringify(mailObject));
And here's the DSL rule to pick it up and send the email:
rule "Mailer"
when
Item Mailtransporter received command
then
if (receivedCommand != NULL && receivedCommand != UNDEF && receivedCommand.toString != "") {
val String json = receivedCommand.toString
val String recipient = transform("JSONPATH", "$.to", json)
val String subject = transform("JSONPATH", "$.subject", json)
val String message = transform("JSONPATH", "$.message", json)
val mailActions = getActions("mail","mail:smtp:yourmail")
mailActions.sendMail(recipient, subject, message)
Mailtransporter.postUpdate("")
}
end
@kstuken What version are you running? I'm on openhab:3.2.0-debian
and get the same error UnsupportedDataTypeException
even via rules DSL, so it's interesting you're only having problems with JS rules. My rule for reference is:
rule "Debug: Send Email"
when
// manual trigger only
Item debug_neverChangingValue changed to "this-wont-happen"
then
getActions("mail", "mail:smtp:migadu").sendMail("<email>", "OpenHAB Test Email", "Sent from OpenHAB")
end
I'm on openhab3.2.0 openhabian and it fails under DSL and JS rules too.
Jan 24, 2022 2:29:08 PM Mark Ormesher @.***>:
@kstuken[https://github.com/kstuken] What version are you running? I'm on openhab:3.2.0-debian and get the same error UnsupportedDataTypeException even via rules DSL, so it's interesting you're only having problems with JS rules. My rule for reference is:
rule "Debug: Send Email" when // manual trigger only Item debug_neverChangingValue changed to "this-wont-happen" then getActions("mail", "mail:smtp:migadu").sendMail("
", "OpenHAB Test Email", "Sent from OpenHAB") end — Reply to this email directly, view it on GitHub[https://github.com/openhab/openhab-addons/issues/11838#issuecomment-1020464022], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AJRFDT2YSN6AMB5ZE67WOLLUXWR6ZANCNFSM5KQXWJRA]. Triage notifications on the go with GitHub Mobile for iOS[https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675] or Android[https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub]. You are receiving this because you commented. [data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD8AAAA/CAYAAABXXxDfAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAAmSURBVGiB7cEBDQAAAMKg909tDwcUAAAAAAAAAAAAAAAAAAAAJwY+QwABivJx1AAAAABJRU5ErkJggg==###24x24:true###][Tracking image][https://github.com/notifications/beacon/AJRFDT4OMHKCUM2QXQ6O2PTUXWR6ZA5CNFSM5KQXWJRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHTJQXFQ.gif]
I am on OH3.2 on openhabian, and using the JSScripting Add-on (ie ECMAScript 2021+ with the underlying openhab-js library). All my rules, as well as the mail thing definition are files based. I have no idea where your case might be failing, but looking at the OH forum it appears others have run into that issue before.
Notes regarding a quick investigation:
text/plain
@kstuken I'm UI based.
Is there some workaround (that doesn't require rewriting the world) to get mail working until a fix can be made?
Just FYI - the command seems to work fine when running it at startup - I have a rule to send me an email every startup (level 100) and this works. However running the rule manually does not work.
FYI: My rule is set to run everyday at 5;30. Today it ran and the email was sent. Just when I click "run now" it gets the error.
UPDATE: I have the DSL rule triggered by the update of a string item. Every time the item is updated the rule fires and sends the email. However, it is only if I click on "run now" in the UI script editor that it returns:
javax.activation.UnsupportedDataTypeException: text/plain; charset=UTF-8
I can confirm this behavior. If the rule is triggered by the trigger (for me it is at a fixed time) the email is sent. If you click on "run now" in the UI you get the error message:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: text/plain; charset=UTF-8
I use a Jython script within the rule..
That's because of a different ClassLoader being used in both cases.
I was hoping that triggering a rule with time would be a good work-around but that's not the case for me.
I THOUGHT this had been an intermittent issue for me before and I have just verified that. I set up a test rule to send an email every 5 minutes and I got 5 in a row.
So then I tried modifying a temp alert rule to trigger every 5 minutes and it did not work.
Then I un-paused the email test rule and it no longer worked.
I created a new email test rule and it did not work.
This is javascript.
This issue has been mentioned on openHAB Community. There might be relevant details there:
Emails started working last night. I have 3 systems running openHABian OH3. I had a test email rule set to send an email on a time trigger (which wasn’t sending any) on one of these systems. I rebooted that system last night and woke up to a bunch of emails. I paused & unpaused the rule & it continues working. So I copied the rule to the other two systems. One started working, the other did not. I rebooted the one that wasn’t sending emails & it’s now working.
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/openhab-3-3-milestone-discussion/132715/37
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/mail-will-not-more-be-send/134230/5
This issue has been mentioned on openHAB Community. There might be relevant details there:
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/cannot-send-mail-no-protocol/135334/10
Expected Behavior
When calling sendMail or sendHtmlMail the email is delivered.
Current Behavior
When calling sendMail the following error occurs:
When calling sendHtmlMail the following error occurs:
In both cases the code is written in JSScripting through the UI. Based on reports (see https://community.openhab.org/t/mail-binding-errors-sending-mail-unsupporteddatatypeexception-text-plaijn-charset-utf-8/130365) the same error occurs in Nashorn and Rules DSL. But there is one report of it working in a .rules file so perhaps the difference is UI verses text file.
Possible Solution
Steps to Reproduce (for Bugs)
Create a Mail thing
Create a UI rule with a script action. Use JavaScript or Rules DSL as the action language and the following line (obviously change the email as appropriate):
actions.get("mail", "mail:smtp:redacted").sendMail("redacted@redacted.com", "Test", "Test")
Watch the logs.
Context
I can no longer get alerts from openHAB via email.
Your Environment
runtimeInfo: version: 3.3.0 buildString: "Build #2651" locale: en-US systemInfo: configFolder: /openhab/conf userdataFolder: /openhab/userdata logFolder: /openhab/userdata/logs javaVersion: 11.0.13 javaVendor: Azul Systems, Inc. javaVendorVersion: Zulu11.52+13-CA osName: Linux osVersion: 5.4.0-91-generic osArchitecture: amd64 availableProcessors: 4 freeMemory: 47455416 totalMemory: 855638016 bindings:
Running in Docker.