Send mails to gmail: connection error

Hi,

I have been using the mail action to send emails triggered by rules via a gmail account. This used to work properly in the past but suddenly stopped working from June 1st.

Every time the rule tries to send a mail there is no mail sent but the following can be found in the logs instead:

2020-06-05 15:25:32.886 [WARN ] [ab.binding.mail.internal.SMTPHandler] - Sending the email to the following server failed : smtp.gmail.com:587 2020-06-05 15:25:32.888 [WARN ] [ab.binding.mail.internal.SMTPHandler] - com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first.

I could not find out how to fix this. I am using Google 2 factor authentication but I have defined an application password and it used to work in the past. I have also set a new password now but it did not change.

Any ideas?

Thanks!

Assuming that setting tls to true in mail.cfg as documented in the readme is correct about all I can offer is that the Mail Binding works with Gmail just fine. You can find a tutorial at How to configure the Mail Binding to use GMail for sending email from openHAB.

Torsten,

I noticed what appears to be the same error today. From looking at my Google account, the last time the binding was able to sent mail was on May 15. I am looking into this as well.

2020-06-10 21:48:35.580 [WARN ] [javax.mail                                    ] - expected resource not found: /META-INF/javamail.default.address.map
2020-06-10 21:48:35.948 [WARN ] [org.openhab.binding.mail.internal.SMTPHandler ] - Sending the email to the following server failed : smtp.gmail.com:587
2020-06-10 21:48:35.949 [WARN ] [org.openhab.binding.mail.internal.SMTPHandler ] - com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first.

Torsten,

I got it working again. In the Thing configuration, I previously had security=“TLS”. I changed it to to security=“STARTTLS”, and it works for me now. I kept the port the same at 587.

5 Likes

Worked for me as well. Thanks a lot!

In the end I got my send mail for a gmail account also working. However I did miss the actions.get(“mail”, “mail:smtp:gmail”) in the official documentation and tried to update this in github (hope i did everything corrrect) My proposal is:

val mailActions = getActions("mail","mail:smtp:justalogicalname") // add in paperUI - configurations - things (from mail binding)
mailActions.sendMail("you@email.net", "Test", "This is the message.", attachmentUrlList)

Wrote this in the style “Openhab for dummies” (so just for myself)
I also benefit from another remark that if in mail.cfg a line is put on comment again this value might still be active.
At the moment I have a small cosmetic problem in the log viewer:

[WARN ] [javax.mail ] - expected resource not found: /META-INF/javamail.default.address.map

Not sure how to solve this (shows up each time an email is generated.
Yesterday I updated to openHAB 2.5.10-1 (Release Build) with the newst java version
This Java version could potentially cause issues, is this one of them?