Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in backend while sending an email message #262

Open
eandersons opened this issue Jan 4, 2024 · 5 comments
Open

Error in backend while sending an email message #262

eandersons opened this issue Jan 4, 2024 · 5 comments

Comments

@eandersons
Copy link

eandersons commented Jan 4, 2024

I cannot manage to get back-end to send email messages.

I launched Quant-UX using Docker Compose:

services:
  database:
    restart: unless-stopped
    image: mongo
    volumes:
      - db-data:/data/db
      - mongo-config:/data/configdb

  frontend:
    restart: unless-stopped
    image: klausenschaefersinho/quant-ux
    environment:
      QUX_PROXY_URL: http://backend:8080
      QUX_AUTH: qux
      QUX_KEYCLOAK_REALM:
      QUX_KEYCLOAK_CLIENT:
      QUX_KEYCLOAK_URL:
      QUX_WS_URL: wss://localhost:8082/ws
    ports:
      - 127.0.0.1:8082:8082
    depends_on:
      - backend

  backend:
    restart: unless-stopped
    image: klausenschaefersinho/quant-ux-backend
    volumes:
      - data:/app-data
    environment:
      QUX_HTTP_HOST: http://localhost:8082  # this is the URL included in the mails, e.g. password resets
      QUX_HTTP_PORT: 8080  # This is the port the backend will use
      QUX_MONGO_DB_NAME: quantux  # the database / collection name in mongodb
      QUX_MONGO_TABLE_PREFIX: quantux  # table / document prefix in mongodb
      QUX_MONGO_CONNECTION_STRING: mongodb://database:27017
      QUX_MAIL_USER: [email protected]
      QUX_MAIL_PASSWORD: 1passwordwith,and;
      QUX_MAIL_HOST: mail.example.org
      QUX_MAIL_PORT: 587
      QUX_MAIL_SSL: required
      QUX_JWT_PASSWORD: quxjwtpassword  # you should change this to a real JWT secret
      QUX_IMAGE_FOLDER_USER: /app-data/qux-images
      QUX_IMAGE_FOLDER_APPS: /app-data/qux-image-apps
      TZ: Europe/Riga
      QUX_AUTH_SERVICE: qux
      QUX_KEYCLOAK_SERVER:  # just the keycloak host & port
      QUX_KEYCLOAK_REALM:
      QUX_USER_ALLOW_SIGNUP: 'true'
      QUX_USER_ALLOWED_DOMAINS: '*'  # comma separated list of domains, e.g. 'my-server.com' or '*' for all
      #QUX_DEBUG: 'true'
    depends_on:
      - database

  websocket:
    restart: unless-stopped
    image: klausenschaefersinho/quant-ux-websocket
    environment:
      QUX_SERVER: http://backend:8080/
      QUX_SERVER_PORT: 8086
    ports:
      - 127.0.0.1:8086:8086
    depends_on:
      - backend

volumes:
  data:
  db-data:
  mongo-config:

, and below is back-end container's log when an email message should be sent:

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
15:03:04.709 [vert.x-eventloop-thread-0] ERROR com.qux.util.Config - mergeUser() > QUX_USER_ALLOW_SIGNUP > true
15:03:04.916 [vert.x-eventloop-thread-0] ERROR com.qux.MATC - createMail() > DISABLE MAIL SSL!
******************************************
* Quant-UX-Server 4.5.6 launched at 8080
******************************************
Jan 04, 2024 3:03:05 PM io.vertx.core.Starter
INFO: Succeeded in deploying verticle
Jan 04, 2024 3:04:02 PM io.vertx.ext.mail.impl.SMTPSendMail
WARNING: sender address not accepted: 530 5.7.0 Must issue a STARTTLS command first
15:04:02.764 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > from: [email protected] >> to : [[email protected]] >> subject : Password Reset >> txt: Dear Name

you have requested a new password. Please follow the link to set a new password:

https://quant-ux.example.org/#/reset_password3.html?id=reallylongid


Your Quant-UX Team.

15:04:02.765 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > Could not send mail to [email protected]
15:04:02.765 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > error:
io.vertx.core.impl.NoStackTraceThrowable: sender address not accepted: 530 5.7.0 Must issue a STARTTLS command first
io.vertx.core.impl.NoStackTraceThrowable: sender address not accepted: 530 5.7.0 Must issue a STARTTLS command first

The same outcome is when I set the environment variable QUX_MAIL_PORT with the value 587 and QUX_MAIL_SSL with the value required (I took a look at back-end's code and it seems that these values are used by default).

I added the environment variable QUX_DEBUG with the value true, and there was no errors in back-end container's log, but email was not received anyway.

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
15:23:49.824 [vert.x-eventloop-thread-0] ERROR com.qux.util.Config - mergeDebug() > QUX_DEBUG > true
15:23:49.832 [vert.x-eventloop-thread-0] ERROR com.qux.util.Config - mergeUser() > QUX_USER_ALLOW_SIGNUP > true
******************************************
* Quant-UX-Server 4.5.6 launched at 8080
******************************************
Jan 04, 2024 3:23:50 PM io.vertx.core.Starter
INFO: Succeeded in deploying verticle
15:25:55.729 [vert.x-eventloop-thread-0] ERROR com.qux.rest.UserREST - error() > *ATTENTION* Wrong login for [email protected]

Everything is working fine with the same email server with Penpot with the following environment variables:

services:
  ...

  backend:
    ...
    environment:
      ...
      PENPOT_SMTP_DEFAULT_FROM: [email protected]
      PENPOT_SMTP_DEFAULT_REPLY_TO: [email protected]
      PENPOT_SMTP_HOST: mail.example.org
      PENPOT_SMTP_PORT: 587
      PENPOT_SMTP_USERNAME: [email protected]
      PENPOT_SMTP_PASSWORD: strongpassword
      PENPOT_SMTP_TLS: 'true'
      PENPOT_SMTP_SSL: 'false'
    ...

  ...

...

, so the issue does not seem to be related to the email server.

Out of curiosity I tried to change the value of QUX_MAIL_PORT to 465, and this time the error was different:

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
15:14:46.331 [vert.x-eventloop-thread-0] ERROR com.qux.util.Config - mergeUser() > QUX_USER_ALLOW_SIGNUP > true
15:14:46.483 [vert.x-eventloop-thread-0] ERROR com.qux.MATC - createMail() > DISABLE MAIL SSL!
******************************************
* Quant-UX-Server 4.5.6 launched at 8080
******************************************
Jan 04, 2024 3:14:46 PM io.vertx.core.Starter
INFO: Succeeded in deploying verticle
15:15:08.791 [vert.x-eventloop-thread-0] ERROR com.qux.rest.UserREST - error() > *ATTENTION* Wrong login for [email protected]
15:20:00.701 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > from: [email protected] >> to : [[email protected]] >> subject : Password Reset >> txt: Dear Name

you have requested a new password. Please follow the link to set a new password:

https://quant-ux.example.org/#/reset_password3.html?id=anotherreallylongid


You Quant-UX Team.
15:20:00.701 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > Could not send mail to [email protected]
15:20:00.701 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > error:
io.vertx.core.impl.NoStackTraceThrowable: connection has been closed by the server
io.vertx.core.impl.NoStackTraceThrowable: connection has been closed by the server

Am I missing something?

@KlausSchaefers
Copy link
Owner

KlausSchaefers commented Jan 4, 2024 via email

@KlausSchaefers
Copy link
Owner

It looks like SSL is disbaled, but expect by the server:

15:03:04.916 [vert.x-eventloop-thread-0] ERROR com.qux.MATC - createMail() > DISABLE MAIL SSL!
...
WARNING: sender address not accepted: 530 5.7.0 Must issue a STARTTLS command first

Can you share your config? By default SSL should be enabled.

@eandersons
Copy link
Author

eandersons commented Jan 7, 2024

Can you share your config?

You mean backend service from Docker Compose file? If so, here it is:

services:
  ...

  backend:
    restart: unless-stopped
    image: klausenschaefersinho/quant-ux-backend
    volumes:
      - data:/app-data
    environment:
      QUX_HTTP_HOST: https://quant-ux.example.org  # this is the URL included in the mails, e.g. password resets
      QUX_HTTP_PORT: 8080  # This is the port the backend will use
      QUX_MONGO_DB_NAME: quantux  # the database / collection name in mongodb
      QUX_MONGO_TABLE_PREFIX: quantux  # table / document prefix in mongodb
      QUX_MONGO_CONNECTION_STRING: mongodb://database:27017
      QUX_MAIL_USER: [email protected]
      QUX_MAIL_PASSWORD: '1passwordwith,and;'
      QUX_MAIL_HOST: mail.example.org
      QUX_MAIL_PORT: 587
      QUX_MAIL_SSL: required
      QUX_JWT_PASSWORD: quxjwtpassword  # you should change this to a real JWT secret
      QUX_IMAGE_FOLDER_USER: /app-data/qux-images
      QUX_IMAGE_FOLDER_APPS: /app-data/qux-image-apps
      TZ: Europe/Riga
      QUX_AUTH_SERVICE: qux
      QUX_KEYCLOAK_SERVER:  # just the keycloak host & port
      QUX_KEYCLOAK_REALM:
      QUX_USER_ALLOW_SIGNUP: 'true'
      QUX_USER_ALLOWED_DOMAINS: '*'  # comma separated list of domains, e.g. 'my-server.com' or '*' for all
      #QUX_DEBUG: 'true'
    depends_on:
      - database

 ...

...

I also updated issue's description with full content of Docker Compose file that reproduces having error [vert.x-eventloop-thread-0] ERROR com.qux.MATC - createMail() > DISABLE MAIL SSL! in backend conteinr's log.

By default SSL should be enabled.

I am aware of that and as I wrote in the issue description, I tried to set the environment variable QUX_MAIL_SSL, but backend container's logs has a row that indicates that SSL is disabled independently of whether or not QUX_MAIL_SSL is used:

The same outcome is when I set the environment variable QUX_MAIL_PORT with the value 587 and QUX_MAIL_SSL with the value required (I took a look at back-end's code and it seems that these values are used by default).

When I attach to the backned container with the aforementioned backend service definition from Docker Compose file and execute echo $QUX_MAIL_SSL, required is printed.

According to code in back-end, the message ERROR com.qux.MATC - createMail() > DISABLE MAIL SSL! should be printed when QUX_MAIL_SSL is explicitly set to optional or disabled:

			if (Config.isMailSSLOptional(config)) {
				logger.error("createMail() > DISABLE MAIL SSL!");
				mailConfig.setStarttls(StartTLSOptions.OPTIONAL);
			} else if (Config.isMailSSLDisabled(config)) {
				logger.error("createMail() > DISABLE MAIL SSL!");
				mailConfig.setStarttls(StartTLSOptions.DISABLED);
			}

When I change QUX_MAIL_SSL to a value other than required, optional or disabled, then the following message is printed in backend container's log: ERROR com.qux.util.Config - mergeMail() > Use 'required','optional' or 'disabled' QUX_MAIL_SSL, which means that the environment variable QUX_MAIL_SSL is taken into account (to some extent at least).

@KlausSchaefers
Copy link
Owner

Hi,

sorry for the late reply. Could you try pulling the latest docker image or remove the QUX_MAIL_SSL?

Thanks,

Klaus

@eandersons
Copy link
Author

Hi Klaus,

I pulled the latest container image and left the environment variable QUX_MAIL_SSL with the value required, and issue seems to be gone - container log does not have the message ERROR com.qux.MATC - createMail() > DISABLE MAIL SSL! and password reset email was successfully received.

When I commented out QUX_MAIL_SSL: required, the issue came back:

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
19:50:23.599 [vert.x-eventloop-thread-0] ERROR com.qux.util.Config - mergeUser() > QUX_USER_ALLOW_SIGNUP > true
19:50:23.723 [vert.x-eventloop-thread-0] ERROR com.qux.MATC - createMail() > DISABLE MAIL SSL!
******************************************
* Quant-UX-Server 4.5.6 launched at 8080
******************************************
Mar 04, 2024 7:50:24 PM io.vertx.core.Starter
INFO: Succeeded in deploying verticle
19:50:50.193 [vert.x-eventloop-thread-0] ERROR com.qux.rest.UserREST - error() > *ATTENTION* Wrong login for [email protected]
Mar 04, 2024 7:50:51 PM io.vertx.ext.mail.impl.SMTPSendMail
WARNING: sender address not accepted: 530 5.7.0 Must issue a STARTTLS command first
19:50:51.200 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > from: [email protected] >> to : [[email protected]] >> subject : Password Reset >> txt: Dear Name
you have requested a new password. Please follow the link to set a new password:
https://quant-ux.example.org/#/reset_password3.html?id=a2aa10aGyMbJjvhwyF2P89vq1xAuuvDaXsi61UVGFpQmOr92j3WbHVONJEQi
You Quant-UX Team.
19:50:51.201 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > Could not send mail to [email protected]
19:50:51.201 [vert.x-eventloop-thread-0] ERROR com.qux.bus.MailHandler - handle() > error: 
io.vertx.core.impl.NoStackTraceThrowable: sender address not accepted: 530 5.7.0 Must issue a STARTTLS command first
io.vertx.core.impl.NoStackTraceThrowable: sender address not accepted: 530 5.7.0 Must issue a STARTTLS command first

, but, as I understand, setting the environment variable QUX_MAIL_SSL with the value required and not specifying it should behave the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants