[SOLVED] Could not invoke method: org.openhab.binding.mail.action.SendMailActions.sendHtmlMail ... on instance: null


I’m using OH 2.5.11 and I noticed that suddenly my SMTP-mail-thing stopped working. I’m using that to send me alerts and errors, therefore it took some days, that I noticed it’s not working anymore.

The thing is configured properly and “ONLINE”.

I’m using following code to send a mail:

val mailActions = getActions("mail","mail:smtp:16158a15")
mailActions.sendHtmlMail("recipient@domain.com", "subject", "html content", attachmentUrlList)

But now retrieve the following error message:

 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'carport movement': An error occurred during the script execution: Could not invoke method: org.openhab.binding.mail.action.SendMailActions.sendHtmlMail(org.eclipse.smarthome.core.thing.binding.ThingActions,java.lang.String,java.lang.String,java.lang.String,java.lang.String) on instance: null


So, obviously first thing I double-checked the thing id, which is correct and as mentioned it’s online. So I also disabled and re-enabled the thing, but it didn’t change. Then I tried to get some more debug logs, maybe I got the command wrong, but following doesn’t add any new logs:

log:set DEBUG org.openhab.binding.mail

Does anyone have a hint what could go wrong or how I could get more information?

Maybe that’s the null culprit, you could log that out.

1 Like

Oh man, didn’t expect that, as I’m just filling that a line above with some image of my cam. But yes it seems like that’s the issue that the cam connection is broken, when I remove this optional parameter it works.

Thanks a lot, I thought it’s somehow related to the smtp instance.

Now you have an opportunity to improve the rule and have it test for this condition , and inform you if it’s broken :wink:

Yes,but you do not want the email to contain the text “file:///C:/openhab/conf/html/carport/ipcamera.gif”. You are expecting the sendmail to go off, find that file, and put the contents of that file in your email.

So if it cannot find the file, or cannot encode the file content for mailing, it will blow up even if the actual attachmentUrlList variable is populated. Blowing up with ‘null’ is not I would have expected, though.

Maybe whatever prepares the file is taking longer than it used to.

1 Like

Yes you’re right, sorry I already marked my comment deleted parallel when retrieving your answer, as it worked then.

The root-cause was obviously an issue in the ip camera not ending the write of the file correctly. Unfortunately, the fix was to reinstall the ip camera binding as well as re-creating the ip camera thing and restarting OH… not really satisfying as a solution path, but it works. :wink:

I’m still surprised the Action fails in that manner. Maybe it is more graceful if given a variable to report to

val success = mailActions.sendMail(...