configuration:
config: mail:smtp:6095998bde
type: mail.sendHtmlMail(“c.hof......er@gmail.com”, “Es klingelt an der Haustür”, “Jemand steht vor der Hausür”, “http://10.0.0.51/jpg/image.jpg”)
label: Sendet eine Mail an Hofi
But that ends in error.
In OH2.5 this had sent a screensot from a camera.
You should use code fences as it can be the spacing that stops YAML from working and no one can see what your using based on your post.
Recommend you check out the Telegram binding. You can send photos, animations like a gif and video mp4 files. Plus you can also send questions with buttons that can turn lights or anything in openHAB on and off remotely. More powerful emails.
The V3 binding just got some updates in the latest snapshot builds and you can see the updated documentation here:
I can’t be sure but that looks a whole lot like the old Mail Action. I don’t think those old 1.x version Actions were ported over to OH 3. Now Actions like that are installed with the bindings instead of separately. So have you installed the Mail binding and configured an SMPT Thing with your SMTP server’s information and credentials? Then you need to pull the Action associated with that Thing to call sendHtmlMail
val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.sendHtmlMail("mail@example.com", "Test subject", "<h1>Header</h1>This is the mail content.", attachmentUrlList)
inputs: {}
id: “6”
label: Sendet eine Mail an Hofi
configuration:
config: mail:smtp:6095998bde
type: mail.sendHtmlMail(“c.ho......er@gmail.com”, “Es klingelt an der Haustür”, “Jemand steht vor der Hausür”, “http://10.0.0.51/jpg/image.jpg”)
The rule then immediately shows an error message when I enter the last part (mail-#@address, subject, link).
INVALID_RULE
Validation of rule 0ca79312a0 has failed! Action Type "mail.sendHtmlMail(“c.ho......er@gmail.com”, “Es klingelt an der Haustür”, “Jemand steht vor der Hausür”, "http://10.0.0.51/jpg/image.jpg")" does not exist!
The link isn’t the reason, it doesn’t work like this either:
“mail.sendHtmlMail(“c.hof.....tter@gmail.com”, “Es klingelt an der Haustür”, “Jemand steht vor der Hausür”, “du nervst”)” does not exist!
OK, so you are using the mail action directly and not from a Script Action. The best I can offer at this point is to file an issue on the binding and see where that goes. I’ve not done that yet so I don’t have any experience to draw from.
I’m too stupid, now I’ve tried it that way:
Script:
val mailActions = getActions(“mail”,“mail:smtp:Google-SMTP-SRV”)
mailActions.sendMail(“c.hofstaetter@gmail.com”, “Es klingelt an der Haustür”, “Jemand steht vor der Hausür”, “http://10.0.0.51/jpg/image.jpg”)
but I get an error message again:
2020-11-13 18:11:12.553 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘0ca79312a0’ failed: :1:4 Expected ; but found mailActions
val mailActions = getActions(“mail”,“mail:smtp:Google-SMTP-SRV”)
^ in at line number 1 at column number 4
OK, I think the problem here is you chose ECMAScript (aka JavaScript) as the language for the Script Action but the code is Rules DSL. I don’t know if you can change the language after the fact or not. You might need to delete it and recreate it. this time select “Rules DSL (v1)” as the “script type”.
Thank you very much, the script is now functional better, only e-mails are still not being sent:
There is only a meaningless error message in the log and I am unable to set the mail binding to DEBUG logging:
2020-11-14 10:39:00.328 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '0ca79312a0' failed: null
I have now switched to “App Password”, but it doesn’t help either.
My rule now looks like this:
At this point all I can offer is to file an issue. There is nothing else obviously wrong. I suggested trying the script action to see if the original problem occurs there’s too, which seems to be the case.
I tried that yesterday, but the wrong script language was selected. Now that the script language fits, thanks to your help, it worked immediately after switching to the identifier.
Thanks for pointing this out, I’ll definitely take a look at this. The function with the button in the message has charm. Since I run smart locks on OH, I could just use them to open the door when someone I like rings the bell.
Hello all, I’m really interesting with realizing simple rule only with UI (and thus without my buggy scripts) but I really don’t find how to send mail from the action part of the rule editor.
At the top of this topic (Nov 13, 2020), there is a print screen that show the user can select to send mail in the actions through a thing. I’ve tryed many thing but it’s impossible for me to choose sendMail… I just have following list :
That never worked. Actions that can’t work are no longer listed. It’s never been possible to send an email without using a Script Action and doing it in code.