Okay, for whatever reason the getActions() did not return you a list containing sendMail() at that moment.
That could happen because -
There is no “mail” binding, or its not running?
There is no “mail:smtp:Mysmtp” Thing known to the mail binding?
Perhaps there is a Thing, but its uninitialized?
Perhaps the Thing is fine, but cannot send mail (e.g.not SMTP type)?
Those would all be legitimate errors, but of course there may be a bug kicking around. At the moment that doesn’t look too likely, because this works for others.
If it works sometimes, there might be a timing issue - for example in OH2 startup rules you could do getActions() before a binding was fully ready, and get this kind of result. Later, it works. You haven’t said if you ever get mails this way.
Logging out the actions object doesn’t tell you much,but at least you can see you got one.
val mailActions = getActions("mail","mail:smtp:Mysmtp")
logInfo("test", "object {}", mailActions)
val success = mailActions.sendMail("colin@xx.com", "HOUSE ALARM TROUBLE ALERT", " The house alarm is detecting a problem" )
logInfo("test", "result " + success)
A non-existent Thing gives logs
2021-03-03 14:17:27.687 [INFO ] [.eclipse.smarthome.model.script.test] - object {}
2021-03-03 14:17:27.693 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'test mail action': actions cannot be null
A valid smtp Thing (with non-working settings) gives
2021-03-03 14:20:29.757 [INFO ] [.eclipse.smarthome.model.script.test] - object org.openhab.binding.mail.action.SendMailActions@133fbe0
2021-03-03 14:20:30.119 [WARN ] [ab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : smtp.gmail.com:25
2021-03-03 14:20:30.120 [WARN ] [ab.binding.mail.internal.SMTPHandler] - com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. f16sm31432698wrt.21 - gsmtp
2021-03-03 14:20:30.122 [INFO ] [.eclipse.smarthome.model.script.test] - result false
A valid smtpThing, but set OFFLINE, gives
2021-03-03 14:24:42.319 [INFO ] [.eclipse.smarthome.model.script.test] - object {}
2021-03-03 14:24:42.320 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'test mail action': actions cannot be null
None of which look quite like yours.
Make very sure you have installed Mail binding v2, and also make sure that you do NOT have Mail Action v1 or Mail binding v1 as well. That should not be possible in OH3, but I don’t think we’ve ever found out what version you are on.