Sendmail not working (2.5.0.M2)


i want to setup mail for notifications including attachments. With the old mail action it was working but after update it isn‘t.

Also after activating legacy addons the mail action is not working.

Then I tried the new mail binding and set up a smtp server thing directly in PaperUI.

After adding the lines of code in the rule it is also not working. „Sendmail is not a member of…“ is The error message in the log.

I tried in the rule with

Val mailActions = getActions...

And without, but everytime the same error. What I have to do to get this running?

See Item 10 especially and give us the FULL log error.


thanks for the answer. You are completely right. For me it’s hard to understand th new documentation about the mail binding. This is the reason why I am asking because I didn’t find anything related in this forum and also on Google.

23:09:58.346 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'Test': The name 'sendMail' cannot be resolved to an item or type; line 12, column 2, length 58

This is the error message from the log when I am running the rule. This is my test rule:

rule "Test"
    Item virt_Test received command
    //val mailActions = getActions("mail", "mail:smtp:gmail")
    logInfo("TEST ", "Regel wird geöffnet")
    sendMail("", "Test-Mail OpenHab ", "Huhu ")

I tried with the “val” command and mailActions.sendMail and without.

There was a typo in the address but also no success:
09:10:42.474 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘Test’: ‘sendMail’ is not a member of ‘org.eclipse.smarthome.core.thing.binding.ThingActions’; line 10, column 2, length 71

You’ve commented out the line that imports the mailActions.

You need to use mailActions.sendMail(...) to call the action.

1 Like

Yes it is just for testing. Normally this is not out commented

Then I try to send the mail with mailActions.sendMail…both are not working

Please post the Rule exactly is it is written for your latest test. What you have posted can never work. We have no idea what you’ve changed since posting that version.

This binding and action does work. I use it and get an email from it several times a day.

The error you quoted is because you failed to import that actions (commented out) and then tried to call sendMail without going through the imported actions.

In case you missed them, here are the examples from the docs:

val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.sendMail("", "Test subject", "This is the mail content.")
import java.util.List

val List<String> attachmentUrlList = newArrayList(
val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.sendHtmlMail("", "Test subject", "<h1>Header</h1>This is the mail content.", attachmentUrlList)
1 Like

I’m having the same issue. here’s some of my info, hoping for a pointer

Thing File:

Thing mail:smtp:pairsmtp [ hostname="", sender="<senderaddress>", security="SSL", username="smtpusername", password="smtppassword-contains-dashes" ]


rule "send mail for testing"

   Time cron "30 36 18 * * ?" 
	val mailActions = getActions("mail","mail:smtp:pairsmtp")
	mailActions.sendMail("", "Openhab Alert", "This is a test email")

Bundles in case it matters

openhab> bundle:list | grep ail
265 │ Active  │  80 │ 1.6.2                 │ JavaMail API
266 │ Active  │  80 │ 1.5.0                 │ Apache Commons Email
267 │ Active  │  80 │ 2.5.0.M2              │ openHAB Add-ons :: Bundles :: Mail Binding

error is:

2019-08-27 18:36:30.100 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘send mail for testing’: ‘sendMail’ is not a member of ‘org.eclipse.smarthome.core.thing.binding.ThingActions’; line 8, column 2, length 89

Is this not loading the “val” correctly? I was using similar info and just upgraded to 2.5.0 M2 today and most things work but I’m struggling to get this going.

I had the same error and it cleared after a cache clean up and a restart

The line
val mailActions …

should read like:

val mailActions = getActions("mail","mail:smtp:cd9c7897")

Where cd9c7897 is a part the thimg UID.

For your thing UID look at
PaperUI -> Things -> SMTP server

Right below the words ‘SMTP server’
there is a line like:

This kind of auto generated thing ID can be replaced by friendlier names when configuring from files, so mail:smtp:pairsmtp can be valid.

But yes, its a good idea for @dotat to look in PaperUI and see if the thing is as expected.

You can also change this name when you first create the Thing.


I personally wish it were required to change it rather than only optionally letting you change it. I highly recommend that for all manually created Things that users replace the auto generated ID with something meaningful.

1 Like

My paperui thing was matching mail:smtp:pairsmtp which I had created in a file. Not sure what helped, but I rebooted (again) and edited my thing file once more with a different name “mail:smtp:pairsmtp3” and edited my thing in paperui and now it’s working. I had tried this a few times 1,2, then the 3 worked for some reason. Should I typically skip doing a .things file and edit directly in paperui?

I now get an error:

[WARN ] [javax.mail                          ] - expected resource not found: /META-INF/

but my email sends fine so I’m not too worried about it. Following another google search, I created a file in the only /META-INF folder I have but it didn’t help:

sudo touch /usr/lib/jvm/zulu-embedded-8-armhf/sample/scripting/scriptpad/src/META-INF/

Happy to report the emails are working at least!

1 Like

Technically it shouldn’t have allowed you to edit the Thing in PaperUI if it’s defined in a .things file. If it did let you without error, any changes you made will be lost on the next reload. You can only define a Thing in one way or the other.

I recommend using PaperUI or the REST API for Things definition.


What about bindings like the Exec binding? I usually do a text file Thing.

I prefer consistency. Because I use automatically discovered Things, to be consistent, I define all my Things through PaperUI or the REST API regardless of the nature of the binding.

When you define your Things through PaperUI you are guaranteed to have a complete and syntactically correct Thing and it’s all self describing, no need to research the parameters and syntax required for each binding you use.

Not quite so easy to backup & restore though.


  1. JSONDB is backed up automatically on every change and periodically. See $OH_USERDATA/jsondb/backups (e.g. /var/lib/openhab2/jsondb/backups).
  2. Running openhab-cli backup/restore also backs up the contents of the JSONDB.
  3. Any manual backup procedure you have must include parts of $OH_USERDATA anyway or else it is an incomplete backup. At a minimum it needs to include jsondb, and binding specific directory (e.g. zwave, mqtt), and persistence. If not it is only a partial backup.
  4. Because the JSONDB is text based, you can even easily check it into git or your source control of choice and see diffs and stuff like that.

If you are manually backing up OH and not including folders like JSONDB from $OH_USERDATA, even if you don’t use PaperUI for anything, your backup is only a partial backup. If you are using openhab-cli to backup, then you are already backing up the jsondb. And if all you need to back up is the jsondb, well that’s handled for you.

I had the same issue, that my getActions() returned null.
I renamed the thing and adapted the rule, and then it worked.
So could be a workaround if someone is facing an issue.

I had the same issue, and a restart fixed it (but I will get the warning noted above).