1

根据https://redash.io/help/open-source/setup设置电子邮件环境变量后(对于 AWS SES)

sudo docker-compose run --rm server manage send_test_mail

有效,我也收到了电子邮件。

但邀请电子邮件不会被发送。

在尝试此命令时 - 直接发送邀请,

sudo docker-compose run --rm server manage users invite x@x.com X admin@x.com

我收到以下错误:

raise RuntimeError('应用程序无法创建 URL '

RuntimeError:应用程序无法为请求独立的 URL 生成创建 URL 适配器。您可以通过设置 SERVER_NAME 配置变量来解决此问题。

4

1 回答 1

0

来自https://github.com/getredash/redash/issues/5266#issuecomment-847756246。感谢@kijimaD。


我也有同样的情况。我找到了一种发送邀请电子邮件的方法。

运行 docker-compose up 后,查看发送浏览器邀请邮件时的日志(↓摘录)。

$ docker-compose up
...
nginx_1             | 172.31.42.153 - - [24/May/2021:10:59:25 +0000] "POST /api/users/124/reset_password HTTP/1.1" 200 122 "https://example.com/users/124" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36" "110.66.19.160"
scheduler_1         | [2021-05-24 10:59:25,960][PID:16][ERROR][ForkPoolWorker-3] task_name=redash.tasks.send_mail task_id=39f69b3c-a109-43d5-bd31-c7dd99955427 Failed sending message: Reset your password
scheduler_1         | Traceback (most recent call last):
scheduler_1         |   File "/app/redash/tasks/general.py", line 58, in send_mail
scheduler_1         |     mail.send(message)
scheduler_1         |   File "/usr/local/lib/python2.7/site-packages/flask_mail.py", line 491, in send
scheduler_1         |     with self.connect() as connection:
scheduler_1         |   File "/usr/local/lib/python2.7/site-packages/flask_mail.py", line 144, in __enter__
scheduler_1         |     self.host = self.configure_host()
scheduler_1         |   File "/usr/local/lib/python2.7/site-packages/flask_mail.py", line 158, in configure_host
scheduler_1         |     host = smtplib.SMTP(self.mail.server, self.mail.port)
scheduler_1         |   File "/usr/local/lib/python2.7/smtplib.py", line 256, in __init__
scheduler_1         |     (code, msg) = self.connect(host, port)
scheduler_1         |   File "/usr/local/lib/python2.7/smtplib.py", line 317, in connect
scheduler_1         |     self.sock = self._get_socket(host, port, self.timeout)
scheduler_1         |   File "/usr/local/lib/python2.7/smtplib.py", line 292, in _get_socket
scheduler_1         |     return socket.create_connection((host, port), timeout)
scheduler_1         |   File "/usr/local/lib/python2.7/socket.py", line 575, in create_connection
scheduler_1         |     raise err
scheduler_1         | error: [Errno 99] Cannot assign requested address
scheduler_1         | [2021-05-24 10:59:25,961][PID:16][INFO][ForkPoolWorker-3] Task redash.tasks.send_mail[39f69b3c-a109-43d5-bd31-c7dd99955427] succeeded in 0.00195795716718s: None
server_1            | [2021-05-24 10:59:28,257][PID:12][INFO][metrics] method=GET path=/health_check endpoint=redash_index status=302 content_type=text/html; charset=utf-8 content_length=311 duration=1.80 query_count=0 query_duration=0.00

显然,错误内容与测试命令一不同。这看起来像是 scheduler_1 实例无法读取端口主机的错误。

换句话说,实例不读取环境变量。我根据这个错误在 docker-compose.yml 中为 worker 添加了一个环境变量。

运行 docker-compose down && docker-compose up -d 后,我可以在浏览器中成功发送邀请邮件。+1 但是,测试命令 docker-compose run --rm server manage users invite user@example.com test-user admin@example.com 不会更改错误消息。

我对 test 命令在特定情况下的可靠性有疑问。显然,测试命令的行为与实际浏览器的行为不同。这似乎让很多人感到困惑……

我对面临相同问题的任何人的建议是操作浏览器并查看日志中的实际错误,而不是使用测试命令进行检查。

我希望这将帮助其他在同样情况下苦苦挣扎的人。

以下是我的 docker-compose 和 env 配置。

码头工人撰写

$ cat docker-compose.yml
version: "2"
x-redash-service: &redash-service
  image: redash/redash:8.0.0.b32245
  depends_on:
    - postgres
    - redis
  env_file: /opt/redash/env
  restart: always
services:
  server:
    <<: *redash-service
    command: server
    ports:
      - "5000:5000"
    environment:
      REDASH_WEB_WORKERS: 4
    env_file: /opt/redash/env
  scheduler:
    <<: *redash-service
    command: scheduler
    environment:
      QUEUES: "celery"
      WORKERS_COUNT: 1
      REDASH_WEB_WORKERS: 4
    env_file: /opt/redash/env # <------------- Add
  scheduled_worker:
    <<: *redash-service
    command: worker
    environment:
      QUEUES: "scheduled_queries,schemas"
      WORKERS_COUNT: 1
      REDASH_WEB_WORKERS: 4
    env_file: /opt/redash/env # <------------- Add
  adhoc_worker:
    <<: *redash-service
    command: worker
    environment:
      QUEUES: "queries"
      WORKERS_COUNT: 2
      REDASH_WEB_WORKERS: 4
    env_file: /opt/redash/env # <------------- Add
  redis:
    image: redis:5.0-alpine
    restart: always
  postgres:
    image: postgres:9.6-alpine
    env_file: /opt/redash/env
    volumes:
      - /opt/redash/postgres-data:/var/lib/postgresql/data
    restart: always
  nginx:
    image: redash/nginx:latest
    ports:
      - "80:80"
    depends_on:
      - server
    links:
      - server:redash
    restart: always
env
$ cat env
PYTHONUNBUFFERED=0
REDASH_LOG_LEVEL=INFO
REDASH_REDIS_URL=redis://redis:6379/0
POSTGRES_PASSWORD=...
REDASH_COOKIE_SECRET=...
REDASH_SECRET_KEY=...
REDASH_DATABASE_URL=...

# Mail
REDASH_MAIL_SERVER=...
REDASH_MAIL_PORT=...
REDASH_MAIL_USE_TLS=...
REDASH_MAIL_USERNAME=...
REDASH_MAIL_PASSWORD=...
REDASH_MAIL_DEFAULT_SENDER=info@example.com
REDASH_HOST=https://example.com
REDASH_SERVER_NAME=https://example.com
于 2021-06-18T03:39:15.167 回答