I’m trying to get mail action to to work in a rule. I get the following error:
[WARN ] [ab.binding.mail.internal.SMTPHandler] - Trying to send mail but exception occured: Sending the email to the following server failed : gamubaru.com:587
I don’t know how to get more details about the exception.
I tried the python sending script using the same credentials:
Sending from the rule, on the mail server side it complains: SSL3 alert read:fatal:certificate unknown.
I tried removing the mail binding, clearing the cache and re-installing the binding.
rule "Dryer State"
when
Item dryerControl changed
then
val mailActions = getActions("mail","mail:smtp:gamubarusmtp")
if(dryerControl.state == 0) {
logInfo("Dryer control", "Off")
mailActions.sendMail("zzzz@gamuaru.com", "Dryer state", "The dryer control is off.")
}
if(dryerControl.state == 1) {
logInfo("Dryer control", "On")
mailActions.sendMail("zzzz@gamuaru.com", "Dryer state", "The dryer control is on.")
}
end
I also tried creating a mail.cfg file. I think that is for the 1.x binding however.
Hi Andy,
did you configure the mail.cfg?
here is mine:
# 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=myuser@gmail.com
password=mypassword
# The email address to use for sending mails
from=openHAB.PIN@gmail.com
# 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=true
# 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=
How can I install Mail Action 2.5? I am running 2.5 stable release but in PaperUI in the Add-ons Actions list I can only find the 1.x version. Did you succeed to install it?
It’s a bug and should show up as legacy. I started to fix this last time it came up in the forum, but stopped myself since it was a waste of time… 1.x compatibility has been removed in OH 3.0.
Mail 2.5 is no longer an Action. You can find it in the Bindings section now. Accessing the action is a little different too. Look in the Binding’s docs to see examples for how. It is available but it’s in a different category.
Over time, I expect the Actions category to completely go away. The OH 2.x way of managing Actions is through Bindings, not as a separate Action add-on.
I tried setting debug logging based on the exception that I had:
log:set DEBUG ab.binding.mail
That does not give me any more information. All I see is: [WARN ] [ab.binding.mail.internal.SMTPHandler] - Trying to send mail but exception occured: Sending the email to the following server failed
Maybe should be org.openhab.binding.mail but not sure as I do not have this binding installed. If you use bundle:list in console it should show everything you have.
patterned my rule off the sample in the binding docs.
val mailActions = getActions("mail","mail:smtp:gamubarusmtp")
mailActions.sendMail("zzzz@gamuaru.com", "Dryer state", "The dryer control is off.")
It looks like I’m doing that part correctly. I’m guessing that there is a problem with my Thing configuration. That seems pretty straight forward however. Not sure how I could mess it up
Assuming the binding is installed correctly, which seems to be the case, there might be something wrong with the Thing. We need to see what that exception is because it could also be a temporary network issue or something like that too.
If it’s not printing the exception in the logs, we need to put the mail binding into debug or trace level logging. The easiest would be to log into the karaf console and issue the command
log:set DEBUG org.openhab.binding.mail
That will put the mail binding and just the mail binding into DEBUG log level. Everything else remains unchanged.