sendtestemail 在 GCE docker-compose 上失败

sendtestemail 在 GCE docker-compose 上失败

我正在 Google Cloud Platform(使用 Container-Optimized OS 的 GCE)上设置 Weblate,并使用 HTTPS 配置通过 Docker Compose 进行部署。

我已经遵循了以下教程:

Weblate 运行良好,但由于以下原因,电子邮件无法发送:

ERROR Handled exception: OSError: [Errno 99] Cannot assign requested address
Traceback (most recent call last):
  File "/usr/local/bin/weblate", line 11, in <module>
    load_entry_point('Weblate==3.8', 'console_scripts', 'weblate')()
  File "/usr/local/lib/python3.7/dist-packages/weblate/runner.py", line 34, in main
    execute_from_command_line(argv)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/commands/sendtestemail.py", line 33, in handle
    recipient_list=kwargs['email'],
  File "/usr/local/lib/python3.7/dist-packages/django/core/mail/__init__.py", line 60, in send_mail
    return mail.send()
  File "/usr/local/lib/python3.7/dist-packages/django/core/mail/message.py", line 291, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.7/dist-packages/django/core/mail/backends/smtp.py", line 103, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python3.7/dist-packages/django/core/mail/backends/smtp.py", line 63, in open
    self.connection = self.connection_class(self.host, self.port, **connection_params)
  File "/usr/lib/python3.7/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.7/smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python3.7/smtplib.py", line 307, in _get_socket
    self.source_address)
  File "/usr/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address

我尝试过使用docker-compose-https.override.yml文件中的各种设置,即省略某些设置以自动配置并更改指定的电子邮件地址、指定邮件端口以及更改 SSL/TLS 设置。

以下是配置的相关部分:


WEBLATE_EMAIL_HOST: "smtp-relay.gmail.com"
WEBLATE_SERVER_EMAIL: "[email protected]"
WEBLATE_DEFAULT_FROM_EMAIL: "[email protected]"
WEBLATE_USE_SSL: 0
WEBLATE_USE_TLS: 1
WEBLATE_ALLOWED_HOSTS: "i18n.example.org"

我不确定问题是什么,也不知道该去哪里解决。有人能给点建议吗?

答案1

问题是我没有指定端口。我的设置的正确配置是:


WEBLATE_EMAIL_HOST: "smtp-relay.gmail.com"
WEBLATE_EMAIL_PORT: 587
WEBLATE_SERVER_EMAIL: "[email protected]"
WEBLATE_DEFAULT_FROM_EMAIL: "[email protected]"
WEBLATE_USE_SSL: 0
WEBLATE_USE_TLS: 1
WEBLATE_ALLOWED_HOSTS: "i18n.example.org"

相关内容