[SOLVED] Getting Mail Action Started with gmail

I have been trying to setup the Mail Action according to the description here: https://www.openhab.org/addons/actions/mail/

After installing the Add-on “Mail Action” in Paper UI, I made this mail.cfg file in the folder services/ with this content:

hostname: smtp.gmail.com
port: 25
username: myemail@gmail.com
password: mypassword
startTLSEnabled: false
sslOnConnect: false

Then I created this rule:

rule “Send email if door opens”
Item Door changed from CLOSED to OPEN
sendMail("myemail@gmail.com", “The door is open”, “The door is open”)

I did a Reboot of the Openhab

There is an error message after reboot in the log file:
[WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line ‘hostname: smtp.gmail.com
[WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line ‘port: 25’
[WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line ‘username: myemail@gmail.com
[WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line ‘password: mypassword’
[WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line ‘startTLSEnabled: false’
[WARN ] [g.dispatch.internal.ConfigDispatcher] - Could not parse line ‘sslOnConnect: false’
[ERROR] [org.apache.felix.configadmin ] - [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=134, bundle=274/mvn:org.openhab.action/org.openhab.action.mail/1.13.0]: Updating property mail of configuration org.openhab.mail caused a problem: Parameters mail:hostname and mail:from are mandatory and must be configured. Please check your openhab.cfg!

Does this mean that the mail.cfg file is incorrect? The syntax is not very clear in the description of the service.

When I open the door I am getting this error in the log file:

Cannot send e-mail because of missing configuration settings. The current settings are: Host: ‘null’, port ‘null’, from ‘myemail@gmail.com’, startTLSEnabled: false, sslOnConnect: false, username: ‘null’

Looks like the mail.cfg file content is disregarded.

What am I doing wrong?

The mail.cfg for gmail should be:


Note the = instead of :

1 Like

Thank you for clarifying the syntax in the config file!

Now, I think it works, the issue now is that Google has some kind of safety issue, I am getting these 3 errors in the logfile:

Could not send e-mail to ‘myemail@gmail.com’.

org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587

Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials p27sm3729671lfo.5 - gsmtp

I got a warning email from Google, which I confirmed that it was me who did the breach, but I think Google has more strict limitations. Is there any way around this?

First if all, the Mail Action is now deprecated (as of OH 2.5 M3) so you will want to move to the new Mail binding in the near future.

As for the problem, do you have to factor authentication enabled? If so, you need to create an application password for OH to use.



Yes you need to remove two step verification from your account

Well, I activated the two step verification and followed the instruction given by Google to produce a 16 digit password for OpenHAB, which I entered into the config file, and now it works. Thank you!

Unless you do that of course…
Well done