Send Mail in Rule Engine (Experimental)

I’m Using the Mail-Action and the Rule-Engine.
Wenn i setup a new rule

When…[something]
Then…(execute a given script)
script: sendMail(“aaa@bbb.cc”, “subjecttext”, “messagetext”)

When i run this rule i get this error in the log
[ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: ReferenceError: “sendMail” is not defined in at line number 1

What is the correct syntax in the rule-engine for sending an email with the mail-action

The same happens when i’m using the action BroadcastNotification
sendBroadcastNotification(“text notification”)
Script execution failed: ReferenceError: “sendBroadcastNotification” is not defined in at line number 1

Looks like your mail.cfg is not correctly defined:

http://docs.openhab.org/addons/actions/mail/readme.html

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

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

# the username and password if the SMTP server requires authentication
username=your_username
password=your_password

# The email address to use for sending mails
from=your_email

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

# set to "true", if SSL negotiation should occur on connection
# do not use both tls=true and ssl=true
# (optional, defaults to false)
ssl=false

# set to "true", if POP before SMTP (another authentication mechanism)
# should be enabled. Username and Password are taken from the above
# configuration (optional, default to false)
popbeforesmtp=false

# Character set used to encode message body
# (optional, if not provided platform default is used)
#charset=

Thx for your response.
I’ve checkt the settings in the mail.cfg again. All parameters seem to be correct.
I think it’s an syntax issue…

This is my “script”

and thats the Errror Message
[ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: ReferenceError: “sendMail” is not defined in at line number 1

Make sure you have

from=your_email_adress

configured.
Otherwise I have no ideas, sorry.

I to get the same error. Mail.cfg is correctly set for Gmail and I’m doing a time based rule in the rule engine.
I’m not sure if the rule engine is working correctly. I have not tried creating a rules file and doing it that way.

Has anyone a working mail configuration with a “sendmail” inside the rule configuration?

Anyone?

My working config is already posted above, no issues so far.

In a rule I’m using a simple:

sendMail("myemailadress@gmail.com", "Test", "This is a test message.")

I am having the same error in the log

[ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: ReferenceError: “sendMail” is not defined in at line number 1

My eMail is still not working, if you found a solution please post how you solve this problem

I checked the mail cfg again

SMTP set for gmail and TLS true and false for SSL.

Read somewhere that you have to change the security for your email acct as well.

But still a no go.

I stopped playing around with that and just created $$.rules file and it’s working fine. Rules don’t show in UI but doesn’t matter to me. Try that as a test and see if your email starts

Can you please upupload a sample of your $$.rules file

Ok let me get home and I will send you copy of it.

Also I used eclipse to get rid of the errors that I was having before.

Ok first install mail action from the UI, then check to ensure you have these set in mail.cfg (look in services folder). I use gmail, sample below:

hostname=smtp.gmail.com
port=587
username=youremail@gmail.com
password=your email password
from=youremail@gmail.com
tls=true
ssl=false
#popbeforesmtp=
#charset=

Here is the rules file, ensure to set your xx.items file as well.

rule “Washer complete"
when
Item Washer changed from ON to OFF
then
sendMail("youremail@gmail.com”,“Washer”,“Done”)
end

In your XX.items file, ensure you have the item setup

Switch Washer “Washer” { channel=“network:device:xxx_xxx_xx_xx:online” }

I am still a noob playing around with this, but got it to work. It won’t show up in the UI, but don’t care for it much, so far pleased with the notifications.