0

I've recently used the docker images provided for Taiga6 to run an instance using docker-compose on Ubuntu 20.04.

Everything seems to work fine, except that I can't seem to get email working quite right. I use Gmail for my company's email, foamfactory.io, but the gmail smtp relay seems to be... finicky at best.

I decided to try using https://github.com/bokysan/docker-postfix to have a simple SMTP relay set up as part of the docker-compose.yml file. I can get the email server to start fine, and it will send emails as expected when I connect to the taiga-back container, install cURL, and run the following command:

curl --url 'smtp://taiga-email:25' --mail-from 'taiga-noreply@foamfactory.io' --mail-rcpt 'jaywir3@gmail.com' --upload-file mail.txt --insecure

However, when I attempt to send an email from Taiga (for example, inviting a user), I get the following exception:

taiga-back_1             | ERROR:2021-02-10 17:42:49,044: Internal Server Error: /api/v1/memberships/4/resend_invitation
taiga-back_1             | Traceback (most recent call last):
taiga-back_1             |   File "/opt/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
taiga-back_1             |     response = get_response(request)
taiga-back_1             |   File "/opt/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
taiga-back_1             |     response = self.process_exception_by_middleware(e, request)
taiga-back_1             |   File "/opt/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
taiga-back_1             |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
taiga-back_1             |   File "/taiga-back/taiga/base/api/viewsets.py", line 104, in view
taiga-back_1             |     return self.dispatch(request, *args, **kwargs)
taiga-back_1             |   File "/opt/venv/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
taiga-back_1             |     return view_func(*args, **kwargs)
taiga-back_1             |   File "/taiga-back/taiga/base/api/views.py", line 458, in dispatch
taiga-back_1             |     response = self.handle_exception(exc)
taiga-back_1             |   File "/taiga-back/taiga/base/api/views.py", line 456, in dispatch
taiga-back_1             |     response = handler(request, *args, **kwargs)
taiga-back_1             |   File "/taiga-back/taiga/projects/api.py", line 1078, in resend_invitation
taiga-back_1             |     services.send_invitation(invitation=invitation)
taiga-back_1             |   File "/taiga-back/taiga/projects/services/invitations.py", line 32, in send_invitation
taiga-back_1             |     email.send()
taiga-back_1             |   File "/opt/venv/lib/python3.7/site-packages/django/core/mail/message.py", line 306, in send
taiga-back_1             |     return self.get_connection(fail_silently).send_messages([self])
taiga-back_1             |   File "/opt/venv/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 103, in send_messages
taiga-back_1             |     new_conn_created = self.open()
taiga-back_1             |   File "/opt/venv/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 70, in open
taiga-back_1             |     self.connection.login(self.username, self.password)
taiga-back_1             |   File "/usr/local/lib/python3.7/smtplib.py", line 697, in login
taiga-back_1             |     "SMTP AUTH extension not supported by server.")
taiga-back_1             | smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server.

The configuration looks like the following inside of docker-compose.yml:

EMAIL_BACKEND: "django.core.mail.backends.smtp.EmailBackend"
DEFAULT_FROM_EMAIL: "taiga-noreply@foamfactory.io"
...
services:
  taiga-email:
    build: ../docker-postfix
    environment:
      ALLOWED_SENDER_DOMAINS: "foamfactory.io"
      RELAYHOST_TLS_LEVEL: "may"
    ports:
      - "1587:${EMAIL_PORT}"
    networks:
      - taiga

I previously had Taiga v5 set up on a host that provided its own email service. We'll call this server email.foamfactory.io. I augmented it so that it would accept connections from the new host server (on which I'm running the docker image for taiga6) and receive email. It does not use TLS, and does not require authentication (the only server that can forward email through it is the one on which the taiga6 docker container is running).

Even with this solution, I'm still getting the error smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported. I'm a bit at my wits end, because I want to use Taiga6, but the conversion to this newer version requires me to send an email invitation so that I can verify the user account for which I want to use.

I guess what I'm wondering is how I can disable SMTP authentication in Django... I want to be able to use unauthenticated SMTP over non-TLS connections, from a specific server to another specific SMTP server.

4

1 回答 1

0

事实证明,问题在于有问题的 SMTP 服务器的基于 IP 的身份验证失败(Django 确实告诉我这一点,但当时我无法正确解释它 - 我认为这是一个 Django 问题,不是 postfix/smtp 主机问题)。

解决方案是在我的 SMTP 服务器中添加以下行:

default_transport = smtp
relay_transport = relay

/etc/postfix/main.cf,以及验证邮件被发送到的服务器的 IP 地址是否已添加到mynetworks

(我从https://serverfault.com/questions/559088/postfix-not-accepting-relay-from-localhost得到这个想法,以在信用到期时给予信用)

当我在管理控制台中设置 SMTP 中继时,我仍然不太清楚为什么它不能与 Gmail 一起使用,但是,就我而言,这个解决方案有效。

于 2021-02-12T17:21:05.160 回答