I’ve spent almost two days trying to make this easy job done, I just wanted to send an email from a rule.
I’ve read the docs and several post around and this was the mail.cfg file I found everywhere and it’s also the default file that cames with OH2, but this one does NOT WORK.
######################## Mail Action configuration ####################################
#
# The SMTP server hostname, e.g. "smtp.gmail.com"
mail:hostname=smtp.gmail.com
# the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS))
mail:port=587
# the username and password if the SMTP server requires authentication
mail:username=xxxxxxxxx@gmail.com
mail:password=xxxxxxxx
# The email address to use for sending mails
mail:from=xxxxxxxxx@gmail.com
# set to "true", if TLS should be used for the connection
# (optional, defaults to false)
mail:tls=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)
#mail:popbeforesmtp=
Well, after capturing the traffic generated from my server with TCPDUMP, I’ve realized that even the docs says that the property mail:popbeforesmtp defaults to false this is WRONG by default this property is TRUE and thats why it didn’t work, so the proper mail.cfg should look like this if you want to connect to GMAIL.
######################## Mail Action configuration ####################################
#
# The SMTP server hostname, e.g. "smtp.gmail.com"
mail:hostname=smtp.gmail.com
# the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS))
mail:port=587
# the username and password if the SMTP server requires authentication
mail:username=xxxxxxxxx@gmail.com
mail:password=xxxxxxxx
# The email address to use for sending mails
mail:from=xxxxxxxxx@gmail.com
# set to "true", if TLS should be used for the connection
# (optional, defaults to false)
mail:tls=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)
mail:popbeforesmtp=false
just to note that I have not changed this value (default is false) and it worked right from the start. Have set up two gmail accounts in two openhab installations without issues
I started working with mail for the first time today and i didnt really have that issue. Worked right out of the box.
config file looks like this:
# The SMTP server hostname, e.g. "smtp.gmail.com"
hostname=smtp.gmail.com
port=587
username=xxxxxx
password=yyyyyy
from=xxxxx@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=
# 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=
#charset=
i left the popbeforesmtp commented out.
Had no problems whatsoever.
The engine is 1.9.0
Hi guys
It is a week that I try to use action mail 1.9.0 (using openhabian), but it never works.
In a first time I thought it was why I have a two factor authentication on gmail, so I changed the mail server, but in the log I find always the previous gmail server. I uninstalled action-mail, I deleted the mail.cfg, afterwards I edited the fresh mail.cfg, but it seems that the system does not read the new cfg. Change of the port/tls has no effect. Any help?
shutdown OH2, clear /var/lib/openhab2/cache & /var/lib/openhab2/tmp, start OH2
Also, remove /var/lib/openhab2/config/org/openhab/mail.config before restart to be sure…
Fix your /etc/openhab2/services/mail.cfg as in example below:
ls -al /var/lib/openhab2/ please
it seems that the permissions are not correct for the tmp folder (can’t write the lock file)
did you change the ownership of the tmp folder after you created it?
(to avoid typing sudo all the time with the openhabian user, switch permanently to root using: sudo su)
When you will start up OH2 again, the service will re-populate the cache and tmp directories with the proper content and you will not have any problems.
If this doesn’t work, re-install the mail action from PaperUI.
Thanks for your reply but it seems the rm commands have broken my system way beyond that. I have followed the post #11 steps but still have issues.
The exec binding was broken but a re-install thru PaperUI fixed that.
The mqtt binding is not working after two re-installs thru PaperUI. I then tried uninstalling the mqtt binding and then re-starting OH2 before again re-installing. It is like mqtt is not installed looking at the logs. I will set logging to DEBUG and report further.
I did the same with the mail-action (Version 1.10.0) and using the gmail settings above. Not getting any response with a basic rule to test an email.
Thanks for any suggestions.