E-Mail Notification failed

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.

2 Likes

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>
1 Like

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?

Yeah, there is some problem.
You can use another mail server like GoDaddy mail, i am using GoDaddy mail and it worked perfectly.

Thanks.
We switched to another email server (not gmail.com) and it is working now.
Seems like STARTTLS is faulty (at least with gmail). And setting it to use TLS solved the problem.

Since @Rich update it works fine with Gmail guys, just configure it like this
update first:
docker-compose -p openremote pull
then docker-compose.yml

environment:
      OR_SETUP_TYPE:
      OR_ADMIN_PASSWORD:
      OR_SETUP_RUN_ON_RESTART:
      OR_EMAIL_HOST: ${OR_EMAIL_HOST:-smtp.gmail.com}
      OR_EMAIL_USER: ${OR_EMAIL_USER:-my@email.com}
      OR_EMAIL_PASSWORD: ${OR_EMAIL_PASSWORD:-myappspecificpassword}
      #OR_EMAIL_PROTOCOL: smtps
      #OR_EMAIL_PORT: 465
      #OR_EMAIL_TLS: "false"

You only need to configure host, user, app-specific password

Hi @pcr
It works now!!
but there is a problem, if i set a rule for an attribute of an asset, (rule=-temp <= 20).
i will received mail regarding temp attribute if the value greater than 20 but when i got mail all attribute values are present on that mail.

My question is that how i get only the specific attribute value @Rich @pcr @martin.peeters @Don

Thanks

Hi @apurba
If you can please share screenshots of the rule configuration and the email received
In my case if I test it with just a boolean attribute that I manually set to true (like this)

I receive this

image

Hi @pcr

Thanks

I just tested it, apparently the variable %TRIGGER_ASSETS% gets all the attribute with “rule state” configuration item.
I tried with %TRIGGER_ATTRIBUTE% but it didn’t work, and I can’t find it in the code

Please see this separate thread regarding notification email format: