Python
sentestemail 在 GCE docker-compose 上失敗
我正在 Google Cloud Platform 上設置 Weblate(使用 Container-Optimized OS 的 GCE)並通過
docker-compose
使用 HTTPS 配置進行部署。我遵循了這些教程:
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: "weblate@example.org" WEBLATE_DEFAULT_FROM_EMAIL: "weblate@example.org" WEBLATE_USE_SSL: 0 WEBLATE_USE_TLS: 1 WEBLATE_ALLOWED_HOSTS: "i18n.example.org" ...
我不確定問題是什麼或在哪裡尋找解決它。
我再次嘗試了我以前的一些嘗試……它似乎手動指定埠是實際的解決方案。
我之前一定是打錯了,或者如果 G Suite 中的外部配置可能導致上述錯誤,那麼設置的更改尚未傳播。
WEBLATE_EMAIL_HOST: "smtp-relay.gmail.com" # THE SOLUTION # WEBLATE_EMAIL_PORT: 587 WEBLATE_SERVER_EMAIL: "weblate@example.org" WEBLATE_DEFAULT_FROM_EMAIL: "weblate@example.org" WEBLATE_USE_SSL: 0 WEBLATE_USE_TLS: 1