Sendmail in OH2

Okay. I’m pretty Close to throw all away. Even th slightest Thing I try does not work.

I’ve installed the mail binding (1.9.0) and configured the mail.cfg with:

# The SMTP server hostname, e.g. "smtp.gmail.com"
hostname=smtp.gmail.com

# the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS/SSL))
port=587

# the username and password if the SMTP server requires authentication
username=somethingb@gmail.com
password=somePW

# The email address to use for sending mails
from=openhab Server

# set to "true", if STARTTLS is enabled (not required) for the connection
# (optional, defaults to false)
tls=true

on top of that I created a rule Myname.rules

rule "send mail for testing"
when 
   Time cron “0 0/1 * * * ?” 
then
   sendMail("destination@provider.com", "This is the email subject", "This is the email body")
end

And this ***** is not working.

Looking at the Karaf log in debug doesn’t show any entry, that the rule gets executed or that an E-Mail is send.

Any help is really appreciated.

Hi, seems you are using the wrong type of quotes around your cron expression, try " instead of “
(I copied your code, did indeed not work, I changed the quotes, it worked)

2 Likes

I’m also using a secure Gmail to send. I’m only using ssl and not TLS (and didn’t define the port).

these work OK for me: (note email/password details altered)

sendMail("waestach@gmail.com", “Laundry” , “Check for Flood!!”)

and my mail.cfg file

hostname=smtp.gmail.com
port=587
username=waestach@gmail.com
password=wrongone123
from=waestach@gmail.com
tls=true

Hi. Thanks for the Reply. Right - the quotes were wrong bit it didn’t work after that either. No signs of sendmail in the logs.
I went for a Devolo Home System and My Troubles have all vanished. Setup was done in not even 30 minutes, and another 15 to set up all rules in the mobile App.

the file mail.cfg is stored on my synology nas in a subfolder of @appstore. Because of this i’m not able to modify/configure this file.
Is the a posobility to add an webinterface to modify this file?

You can access these files by creating a symbolic link, e.g. “ln -s /volume1/@appstore/openHAB2 /volume1/public/openHAB2”. This is much easier than asking the Openhab developers creating a webui. :slightly_smiling_face: