Graylog2 / graylog-docker

Official Graylog Docker image
https://hub.docker.com/r/graylog/graylog/
Apache License 2.0
361 stars 133 forks source link

Email settings, set with env-variables do not work #162

Closed zingi closed 3 years ago

zingi commented 3 years ago

When I set the email settings via env variables in the docker-compose.yml file, I always get an authentication error when I try to send emails.

env settings ```yaml environment: # CHANGE ME (must be at least 16 characters)! GRAYLOG_PASSWORD_SECRET: 'somepasswordpepper' # Password: admin # echo -n yourpassword | shasum -a 256 GRAYLOG_ROOT_PASSWORD_SHA2: '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918' GRAYLOG_ROOT_USERNAME: 'admin' GRAYLOG_HTTP_EXTERNAL_URI: 'http://127.0.0.1:9000/' GRAYLOG_TRANSPORT_EMAIL_ENABLED: 'true' GRAYLOG_TRANSPORT_EMAIL_HOSTNAME: 'mail.example.at' GRAYLOG_TRANSPORT_EMAIL_PORT: 587 GRAYLOG_TRANSPORT_EMAIL_USE_TLS: 'true' GRAYLOG_TRANSPORT_EMAIL_USE_SSL: 'false' GRAYLOG_TRANSPORT_EMAIL_USE_AUTH: 'true' GRAYLOG_TRANSPORT_EMAIL_USERNAME: 'error@example.com' GRAYLOG_TRANSPORT_EMAIL_AUTH_PASSWORD: 'mypassword' GRAYLOG_TRANSPORT_EMAIL_SUBJECT_PREFIX: '[graylog]' GRAYLOG_TRANSPORT_EMAIL_FROM_EMAIL: 'error@example.com' ```

Error:

The Graylog server encountered an error while trying to send an email. This is the detailed error message: org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.example.at:587 (javax.mail.AuthenticationFailedException: 535 5.7.8 Error: authentication failed: VXNlcm5hbWU6 )

However when I create a graylog.conf with the email credentials and map it like:

volumes:
      - ./graylog.conf:/usr/share/graylog/data/config/graylog.conf:ro

it works.


_Version: Graylog 4.0.7+c3e766c on ca97a94894c0 (Oracle Corporation 1.8.0292 on Linux 4.19.0-13-amd64)

(maybe related: #81 )

malcyon commented 3 years ago
  GRAYLOG_TRANSPORT_EMAIL_USERNAME: 'error@example.com'
  GRAYLOG_TRANSPORT_EMAIL_AUTH_PASSWORD: 'mypassword'

@zingi Shouldn't it be GRAYLOG_TRANSPORT_EMAIL_AUTH_USERNAME?

malcyon commented 3 years ago

It works for me with this config:

services:
  elasticsearch:
    environment:
      ES_JAVA_OPTS: -Xms512m -Xmx512m
      bootstrap.memory_lock: "true"
      discovery.type: single-node
      http.host: 0.0.0.0
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.0
    mem_limit: 1g
    ulimits:
      memlock:
        hard: -1
        soft: -1
  graylog:
    image: graylog/graylog:4.0.7-1
    depends_on:
      elasticsearch:
        condition: service_started
      mongo:
        condition: service_started
    entrypoint: /usr/bin/tini -- wait-for-it elasticsearch:9200 --  /docker-entrypoint.sh
    environment:
      GRAYLOG_MESSAGE_JOURNAL_ENABLED: "false"
      GRAYLOG_NODE_ID_FILE: /usr/share/graylog/data/config/node-id
      GRAYLOG_PASSWORD_SECRET: somepasswordpepper
      GRAYLOG_ROOT_PASSWORD_SHA2: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
      GRAYLOG_HTTP_BIND_ADDRESS: "0.0.0.0:9000"
      GRAYLOG_HTTP_PUBLISH_URI: "http://localhost:${GRAYLOG_API_HTTP_PORT:-9000}/"
      GRAYLOG_HTTP_EXTERNAL_URI: "http://localhost:${GRAYLOG_API_HTTP_PORT:-9000}/"
      GRAYLOG_HTTP_ENABLE_CORS: "true"
      # To make reporting (headless_shell) work inside a Docker container
      GRAYLOG_REPORT_DISABLE_SANDBOX: "true"
      #Email settings
      GRAYLOG_TRANSPORT_EMAIL_ENABLED: "True"
      GRAYLOG_TRANSPORT_EMAIL_HOSTNAME: "smtp.gmail.com"
      GRAYLOG_TRANSPORT_EMAIL_PORT: "587"
      GRAYLOG_TRANSPORT_EMAIL_USE_AUTH: "True"
      GRAYLOG_TRANSPORT_EMAIL_AUTH_USERNAME: "EMAIL_ADDRESS_REMOVED"
      GRAYLOG_TRANSPORT_EMAIL_AUTH_PASSWORD: "PASSWORD_REMOVED"
      GRAYLOG_TRANSPORT_EMAIL_SUBJECT_PREFIX: "[graylog]"
      GRAYLOG_TRANSPORT_EMAIL_FROM_EMAIL: "admin@localhost"
      GRAYLOG_TRANSPORT_EMAIL_USE_TLS: "true"
    links:
    - mongo
    - elasticsearch
    mem_limit: 1g
    ports:
    - published: 9000
      target: 9000
    - published: 514
      target: 514
    - published: 5555
      target: 5555
    - published: 12201
      target: 12201
    restart: always
    #volumes:
    #  - ./graylog.conf:/usr/share/graylog/data/config/graylog.conf:ro
  mongo:
    image: mongo:4.2
    mem_limit: 128m
version: '2'
zingi commented 3 years ago

@juju2112 TRUE! now I feel stupid 🤦‍♂️ I spent hours trying to figure out, why it doesn't work...

@kroepke @juju2112 Suggestion for improvement: You could log a warning to stdout, if someone tries to use a env variable setting which does not exist.

If you show me the code location where the env variables are parsed, I can also try to make a PR.