OH3: Jython an mail-binding - send mail (SMTP) does not work

Hi there,

i have a question about the mail-binding in combination with a Jython script.
This part of the script worked with Telegram, but here the import of “Things” does not work.

from core.actions import Things

def send_mail(event):
  mailActions = Things.getActions("mail","mail:smtp:gmail")
  mailActions.sendHtmlMail("xxx@gmail.com", "Test subject", "<h1>Header</h1>This is the mail content.")

My binding was configured as follows:

UID: mail:smtp:gmail
label: SMTP GMAIL
thingTypeUID: mail:smtp
configuration:
  security: SSL
  hostname: smtp.gmail.com
  password: xxxpwdxxx
  sender: "openHAB "
  port: "465"
  username: xxx@gmail.com

Can someone tell me where the problem is, unfortunately i can’t figure it out… that would be great!

Thanks in advance,
Christoph

When using the Helper Libraries, Helper Libraries for openHAB Scripted Automation — openHAB Helper Libraries documentation should always be the first place to look. In particular for Actions Actions — openHAB Helper Libraries documentation.

Look at the example. Importing Things is to get the status for a given Thing. For example, is my Zwave controller ONLINE? You are trying to use an Action provided by a Thing. Scrolling down just a little bit you will see an MQTT 2 Example which shows how to do it.

Thanks @rlkoshak , now it works!

actions.get("mail", "mail:smtp:gmail").sendMail("xxx@gmail.com",  "openHAB Alert", "Test")