Using GMAIL to send mail with the Mail Action 1.9.0.b5

@cgeo which version of Action Mai are you using? 1.9.0.b5?

PaperUI reports 1.9.0. It is the one that comes with the stable 2.0 release
How can I see the details ?

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:

hostname=smtp.gmail.com
port=587
username=someone@gmail.com
password=somepass
tls=true
ssl=false
popbeforesmtp=false

With mail.cfg fixed, OH2 will recreate /var/lib/openhab2/config/org/openhab/mail.config upon startup and repopulate tmp & cache folders

Please likely a stupid question, I am a very beginner, so must i scratch all the files in the directory?


thanks

Yes. It’s all recreated on a current state after restart of openHAB.

1 Like

Yes. Also the subdirectories. In both directories.

systemctl stop openhab2
rm -rf /var/lib/openhab2/tmp/*
rm -rf /var/lib/openhab2/cache/*
rm /var/lib/openhab2/config/org/openhab/mail.config
systemctl start openhab2
tail -f /var/log/openhab2/openhab.log -f /var/log/openhab2/events.log

careful with rm -rf ! :slight_smile: (better use rm -ri to see what you are deleting)

unfortunately I had already used rm -R cache (and tmp), now I cannot restart xxx:8080 and I realized that all the things and items has been deleted

Cache and temp don’t hold config data.
Hopefully you didn’t remove /var/lib/openhab2/ dir… (which includes jsondb folder)
Is this dir still there?

le directory are there,

but xxx:8080 does not work
and

did you systemctl start openhab2 ?
what does the log say after that?

re-create the tmp subdirectory. it seems that you removed it (you should have removed only its contents /*)

mkdir /var/lib/openhab2/tmp/
chown openhab:openhabian /var/lib/openhab2/tmp/

I created tmp
this is the status of openhab

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)

I have used these rm commands also and now have :
FileNotFoundException: /var/lib/openhab2/cache/org.eclipse.osgi/185/0/.cp/lib/commons-email-1.4.jar

even after a re-start of OH2 and a cold reboot.

ls -la /var/lib/openhab2/cache only shows
drwxrwxr-x+ 4 openhab openhabian 4096 Oct 25 10:09 .
drwxrwxr-x+ 13 openhab openhabian 4096 Oct 14 17:27 …
-rw-rw-r-- 1 openhab openhab 38486 Oct 25 10:09 1508881579466.log
drwxrwxr-x+ 3 openhab openhabian 4096 Oct 25 00:03 org.eclipse.core.runtime
drwxrwxr-x+ 203 openhab openhabian 4096 Oct 25 09:44 org.eclipse.osgi

Is there a repair I can do or do I need to do a complete re-install?

You need to follow the steps from post # 11

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.

mqtt working again after a new apt-get install and re-installing the binding.
Mail still not working correctly as it must have old authentication details in a cache somewhere as it continues to fail authentication on correct and current details. Re-starts and re-installs do not resolve the problem and I am reluctant to go through the whole rm thing again after what has happened.
It would be nice to have a clean and simple way to flush the cache as this seems to be an issue with the Mail-Action.
EDIT
It seems my problem may relate to permissions for /var/log/exim4. This probably stems from using tmpfs to mount /var/log so as to avoid regular SD card failures. I need to research this one to see if OH have a packaged solution or raise a new issue for it.
Mail still not working. Pity. I had great hopes for it.

With regards to your example I learned 2 things:

  • the from-parameter is mandatory. You must not omit it (like in your example)
  • Google notified me that it had blocked the access of processing the email due to an “insecure account access”.
    ** What needs to be done is to go the settings in your goofle Account and set “allow less secure apps” to ON (which is not recommended by Google).

Hope that helps someone who had similar issues like I did

1 Like

Hello,

hier is my Config

# 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=578

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

# The email address to use for sending mails
from=XXX@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=

And very important to turn on this http://prntscr.com/m4dsgw security feature in Gmail on this url https://myaccount.google.com/lesssecureapps
Without it has not worked!