[SOLVED] Mail Action missing

Hardware: Intel Q9650 on Dell 0G261D motherboard
OS: Ubuntu 18.04.1 LTS
JRE: OpenJDK 1.8.0_192
OpenHAB 2.5.0.M3

Hopefully a simple question: I cannot see the Mail action available to install. I want to send SMS text notifications and had this working successfully in the past before my openhab reload. Did this Action go away in the 2.5 build?

Sometime around 2.5 M2 a Mail binding was released which replaced the Mail Action. This the Mail Action went to Legacy. You can see it if you turn on “show Legacy 1.x bindings” in PaperUI and it will show up again. Or, better, you can find the new Mail binding under bindings.

yeah for Calvin!
where is @Spaceman_Spiff Seb

2 Likes

Thanks, Rich. I’d seen the Mail binding and reviewed it, but it looks like it only does email; is there a current method to “text” as the old action did? I just found it more effective, I pay more attention to texts than I do to email.

I went back and looked at my rules, and should mention that I was actually using the ability of AT&T to convert an email to a text for me ("xxxxxxxxxx@txt.att.net"). So I guess all I need is the Mail binding…
But I’m getting the error in the logs

Error during the execution of rule 'Test': The name 'sendMail' cannot be resolved to an item or type; line 116, column 4, length 53

which would indicate (normally) that the binding is not installed.

Can you post your rule, please?

The mail action is part of the mail binding, please take a look at the documentation.

Thanks, all. I did begin reviewing the binding information after my posting and began some attempts to replicate it. I’m still struggling a bit, this is what I have:



import java.util.List
//
// TEST MAIL RULE
rule "Mail Test"
when
   Time cron "0 09 20 ? * * *"
then
   val mailActions = getActions("mail","mail:smtp:att_smtp")
   mailActions.sendMail ("xxxxxxxxx@txt.att.net", "SAFETY", "TesT")
   sendBroadcastNotification("TesT")
   //actions.get("mail", "mail:smtp:att_smtp").sendMail("xxxxxxxxx@txt.att.net", "SAFETY", "Test")
end

where the “xxx…x” is my cell phone number. You can see I was trying a few alternatives. The “import.” statement is at the top of my rules.

I have also set up a thing:

Thing mail:smtp:att_smtp [ hostname="smtp.gmail.com", sender="xxx@gmail.com" ]

Not sure how to align this with a rule going to att.txt

@DaveL Your phonenumber is still visible, you only commented it in one place.

I’m pretty sure you have to set credentials, too, smtp is never working without user/passwd.

Thing mail:smtp:samplesmtp [ hostname="smtp.example.com", sender="mail@example.com", security="TLS", username="user", password="pass" ]

and then:

val mailActions = getActions("mail","mail:smtp:samplesmtp")
mailActions.sendMail("mail@example.com", "Test subject", "This is the mail content.")

import java.util.List is only used when sending multiple attachments.

The Thing should be marked as ONLINE in Paper UI.
In the rule, you can check wether mailActions is still null after assignment, or not.

Finally getting back to this after working all of the bugs out of my MQTT server and wifi items.

I have the entries entered according to the binding instructions. I’m using my gmail account to get the bugs worked out. My .thing looks like:

Thing mail:smtp:testmail [ hostname="smtp.gmail.com", sender="myaccount@gmail.com", username="myaccount@gmail.com", password="mypassword" ]

I’m not seeing a thing listed in PaperUI although there had been one there before.

My messaging rule is:

rule "Mail Test"
when
   Time cron "0 13 20 ? * * *"
then
   val mailActions = getActions("mail","mail:smtp:testmail")
   mailActions.sendMail("myaccount@gmail.com", "This is the content")
end

I’m getting the following error in the logs when the rule executes:

2019-10-26 20:13:00.091 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Mail Test': An error occurred during the script execution: index=3, size=3

Is this an issue with the .thing configuration?

My error, my thing is there: SMTP Server. So that seems to be working…

Success!

Update, here is where I am:
The rule seems to be executing correctly; no more errors there (my mailActions line was not formatted correctly, I was missing the “title” entry). It’s now:

mailActions.sendMail("myaccount@gmail.com", "Test subject", "This is the mail content.")

I also updated my .thing to:

Thing mail:smtp:testmail [ hostname="smtp.gmail.com", sender="myaccount@gmail.com", security="TLS", port=587, username="myaccount@gmail.com", password="mypassword" ]

I then started to get errors related to gmail, and had to change my google account security settings to allow access from less secure apps.

Is there a better free email service to use solely for messaging?