You need to look at the startup section of the logs, when the EmailNotificationHandler
is initialised it tries to connect to the SMTP server and there you should see more information about the failure.
Seems like he doesnât like my credentials, but I tried with two different passwords
Iâll try to investigate more, I really donât understand whatâs wrong
manager_1 | 2023-04-26 10:36:42.026 SEVERE [main ] er.notification.EmailNotificationHandler : Failed to connect to SMTP server so disabling email notifications
manager_1 | org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: gmail.smtp.com, 587; timeout -1;
manager_1 | nested exception is:
manager_1 | java.net.UnknownHostException: gmail.smtp.com
manager_1 | at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2258)
manager_1 | at org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:753)
manager_1 | at jakarta.mail.Service.connect(Service.java:364)
manager_1 | at jakarta.mail.Service.connect(Service.java:222)
manager_1 | at jakarta.mail.Service.connect(Service.java:171)
manager_1 | at org.openremote.manager.notification.EmailNotificationHandler.init(EmailNotificationHandler.java:106)
manager_1 | at org.openremote.container.Container.start(Container.java:162)
manager_1 | at org.openremote.container.Container.startBackground(Container.java:207)
manager_1 | at org.openremote.manager.Main.main(Main.java:31)
manager_1 | Caused by: java.net.UnknownHostException: gmail.smtp.com
manager_1 | at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567)
manager_1 | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
manager_1 | at java.base/java.net.Socket.connect(Socket.java:633)
manager_1 | at java.base/java.net.Socket.connect(Socket.java:583)
manager_1 | at org.eclipse.angus.mail.util.SocketFetcher.createSocket(SocketFetcher.java:361)
manager_1 | at org.eclipse.angus.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
manager_1 | at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2208)
manager_1 | ... 8 more
manager_1 | 2023-04-26 10:36:42.028 INFO [main ] er.notification.EmailNotificationHandler : SMTP credentials are not valid so email notifications will not function
Looks like youâve got your host the wrong way around should be smtp.gmail.com
I canât believe myself right now, gonna cry in a corner
Simple mistakes happen
Hopefully all working for you now
Thanks Rich
I tried again (with correct smtp) with the following combinations (and even a new password)
with 587 and STARTTLS I get
Notification failed '122090': Target{type=CUSTOM, id=my@email.com}, reason=Email send failed: 530 5.7.0 Must issue a STARTTLS command first. c16-20020a05600c0ad000b003f198dfbbfcsm12234427wmr.19 - gsmtp
with 587 and true I get
Notification failed '122098': Target{type=CUSTOM, id=my@email.com}, reason=Email send failed: 530 5.7.0 Must issue a STARTTLS command first. n16-20020a05600c181000b003f046ad52efsm21274706wmp.31 - gsmtp
With 465 and true
manager_1 | 2023-04-26 14:50:33.862 SEVERE [main ] er.notification.EmailNotificationHandler : Failed to connect to SMTP server so disabling email notifications
manager_1 | jakarta.mail.MessagingException: Got bad greeting from SMTP host: smtp.gmail.com, port: 465, response: [EOF]
manager_1 | at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2246)
manager_1 | at org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:753)
manager_1 | at jakarta.mail.Service.connect(Service.java:364)
manager_1 | at jakarta.mail.Service.connect(Service.java:222)
manager_1 | at jakarta.mail.Service.connect(Service.java:171)
manager_1 | at org.openremote.manager.notification.EmailNotificationHandler.init(EmailNotificationHandler.java:106)
manager_1 | at org.openremote.container.Container.start(Container.java:162)
manager_1 | at org.openremote.container.Container.startBackground(Container.java:207)
manager_1 | at org.openremote.manager.Main.main(Main.java:31)
manager_1 | 2023-04-26 14:50:33.864 INFO [main ] er.notification.EmailNotificationHandler : SMTP credentials are not valid so email notifications will not function
With 465 and SSL I get
manager_1 | 2023-04-26 14:54:03.824 SEVERE [main ] er.notification.EmailNotificationHandler : Failed to connect to SMTP server so disabling email notifications
manager_1 | jakarta.mail.MessagingException: Got bad greeting from SMTP host: smtp.gmail.com, port: 465, response: [EOF]
manager_1 | at org.eclipse.angus.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2246)
manager_1 | at org.eclipse.angus.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:753)
manager_1 | at jakarta.mail.Service.connect(Service.java:364)
manager_1 | at jakarta.mail.Service.connect(Service.java:222)
manager_1 | at jakarta.mail.Service.connect(Service.java:171)
manager_1 | at org.openremote.manager.notification.EmailNotificationHandler.init(EmailNotificationHandler.java:106)
manager_1 | at org.openremote.container.Container.start(Container.java:162)
manager_1 | at org.openremote.container.Container.startBackground(Container.java:207)
manager_1 | at org.openremote.manager.Main.main(Main.java:31)
manager_1 | 2023-04-26 14:54:03.825 INFO [main ] er.notification.EmailNotificationHandler : SMTP credentials are not valid so email notifications will not function
Is this what you have tried? Note the need to use app specific passwords for authentication:
TLS/STARTTLS on port 587:
OR_EMAIL_HOST:smtp.gmail.com
OR_EMAIL_USER: email_address
OR_EMAIL_PASSWORD: app_specific_password
SSL on port 465:
OR_EMAIL_PROTOCOL: smtps
OR_EMAIL_PORT: 465
OR_EMAIL_TLS: false
OR_EMAIL_HOST:smtp.gmail.com
OR_EMAIL_USER: email_address
OR_EMAIL_PASSWORD: app_specific_password
yes STARTTLS doesnât seem to work
tried second one (I didnât have protocol:smtps) and I get
services.manager.environment.OR_EMAIL_TLS contains false, which is an invalid type, it should be a string, number, or a null
Tried commenting out TLS, same error as before
manager_1 | jakarta.mail.MessagingException: Got bad greeting from SMTP host: smtp.gmail.com, port: 465, response: [EOF]
Yes iâm using app-specific password
Hi,
i configured as per your suggestion but i am getting error
Notification failed â1119â: Target{type=CUSTOM, id=qwerty@gmail.com}, reason=Email send failed: Couldnât connect to host, port: localhost, 25; timeout -1
my configuration
OR_EMAIL_PROTOCOL: smtps
OR_EMAIL_PORT: 465
OR_EMAIL_TLS: false
OR_EMAIL_HOST: smtp.gmail.com
OR_EMAIL_USER: apurba@lazot.com
OR_EMAIL_PASSWORD: xxxxxxxxxx
OR_EMAIL_X_HEADERS:
OR_EMAIL_FROM: apurba@lazot.com
kindly suggest if anything changes needed and i pulled latest manger also.
I guess the docker compose parser is getting stricter; just put quotes around the boolean value
Funny that true is considered a string and false is not lol
Now i get this
Notification failed '122165': Target{type=CUSTOM, id=my@email.com}, reason=Email send failed: Couldn't connect to host, port: localhost, 25; timeout -1```
Seems like he's trying to connect to itself on standard 25 port
Please provide the startup log section where EmailNotificationHandler
is initialised and also the relevant section of your docker compose file (with sensitive data removed).
Hi Rich,
Got this below error in ui log
âNotification failed â1046â: Target{type=CUSTOM, id=koleyapurba007@gmail.com}, reason=Email send failed: Couldnât connect to host, port: localhost, 25; timeout -1â
Pls check below log in starting
my yml file
environment:
OR_SETUP_TYPE:
OR_ADMIN_PASSWORD:
OR_SETUP_RUN_ON_RESTART:
OR_EMAIL_PROTOCOL: smtps
OR_EMAIL_PORT: 465
OR_EMAIL_TLS: false
OR_EMAIL_HOST: smtp.gmail.com
OR_EMAIL_USER: xxxx@lazot.com
OR_EMAIL_PASSWORD: xxxxxxxxx
OR_EMAIL_X_HEADERS:
OR_EMAIL_FROM: xxx@lazot.com
OR_HOSTNAME: ${OR_HOSTNAME:-localhost}
OR_ADDITIONAL_HOSTNAMES: ${OR_ADDITIONAL_HOSTNAMES:-}
OR_SSL_PORT: ${OR_SSL_PORT:â1}
OR_DEV_MODE: ${OR_DEV_MODE:-false}
Thanks
Looks like an issue with the mechanism the EmailNotificationHandler
uses to send the emails; so the initial connection test during initialisation succeeds but it is never able to actually send an email.
This looks like it might be an issue relating to smtps
and the static Transport.send()
method not picking up the fact that we want smtps
so it doesnât find the configured java mail properties.
I would suggest using gmailâs port 587 with TLS rather than using the SSL endpoint for now until we get this fixed. So this means just remove the OR_EMAIL_TLS
, OR_EMAIL_PORT
and OR_EMAIL_PROTOCOL
environment variables as the defaults should work with gmail.
hi,
i tried but getting below error
environment:
OR_SETUP_TYPE:
OR_ADMIN_PASSWORD:
OR_SETUP_RUN_ON_RESTART:
#OR_EMAIL_PROTOCOL: smtps
#OR_EMAIL_PORT: 587
#OR_EMAIL_TLS: STARTTLS
OR_EMAIL_HOST: smtp.gmail.com
OR_EMAIL_USER: xxxxx@lazot.com
OR_EMAIL_PASSWORD: xxxxxxxxxx
OR_EMAIL_X_HEADERS:
OR_EMAIL_FROM: xxxxxx@lazot.com
Thanks
Seems there was a bigger issue with start TLS config in email notifications; just created a PR that fixes this and once all tests pass it will be merged and a new docker image will be pushed to docker hub in the next hour or so; please try with this and should all work.
hi,
which configuration should i follow for gmail configuration?
tried many combination but not working and i got below error
Notification failed â1422â: Target{type=CUSTOM, id=xxx@lazot.com}, reason=Email send failed: 530 5.7.0 Must issue a STARTTLS command first. g13-20020a170902868d00b001a221d14179sm19927279plo.302 - gsmtp
configuration
OR_EMAIL_PORT: ${OR_EMAIL_PORT:-587}
OR_EMAIL_TLS: ${OR_EMAIL_TLS:-STARTTLS}
OR_EMAIL_HOST: smtp.gmail.com
OR_EMAIL_USER: xxxxx@lazot.com
OR_EMAIL_PASSWORD: cbgyekosqsthwhfe
OR_EMAIL_X_HEADERS:
OR_EMAIL_FROM: xxxxxx@lazotâŚcom
OR_EMAIL_ADMIN:
OR_HOSTNAME: 192.168.29.47
OR_ADDITIONAL_HOSTNAMES: ${OR_ADDITIONAL_HOSTNAMES:-}
OR_SSL_PORT: ${OR_SSL_PORT:â1}
OR_DEV_MODE: ${OR_DEV_MODE:-false}
after test rule , i got below error
<<< Attribute event processing took a long time 110ms: attribute=Asset ID=5WwlRHoLh1EUn3Ls8d6GEX, Asset name=purifier, Attribute{name=âTemperatureâ, value=â65.0â, timestamp=â1683045567277â} , consumer=null, timings=GatewayService{active=true}=0ms AgentService{}=1ms RulesService{}=2ms AssetDatapointService{}=95ms AttributeLinkingService{}=1ms
Are you sure you have the latest manager docker image?
I tested the changes with my own gmail and it worked fine:
OR_EMAIL_HOST: smtp.gmail.com
OR_EMAIL_USER: <FULL EMAIL ADDRESS HERE>
OR_EMAIL_PASSWORD: <GOOGLE APP PASSWORD HERE>
Hi, I am also having trouble to get the email to send. I followed the instructions and did a âdocker pull openremote/managerâ to make sure I have the latest image. I am using smtp.gmail.com mail server. The warning is âNotification failed â12802â: Target{type=USER, id=6551ad41-4244-49c0-b7bf-a9988fa73cb4}, reason=Email send failed: 530 5.7.0 Must issue a STARTTLS command first. e21-20020a62ee15000000b0064fdf5b1d7esm732336pfi.157 - gsmtpâ.
Any idea how to solve this?
We googling on the above and some said that gmail doesnât work with STARTTLS but uses TLS. So I changed the setting to
OR_EMAIL_TLS: ${OR_EMAIL_TLS:-true}
After restarting docker, and testing the sending of email, the error changes to not valid email instead of need to issue STARTTLS command first.
Error processing from REALM_RULESET - NOTIFICATION_HANDLER_CONFIG_ERROR (Handler is not valid: email): Notification{name=ânullâ, message=org.openremote.model.notification.EmailNotificationMessage@26cb95d3, repeatFrequency=null, repeatInterval=ânullâ, targets=[Target{type=USER, id=6551ad41-4244-49c0-b7bf-a9988fa73cb4}]}
Any idea how to solve this?