python - smtplib.SMTPNotSupportedError:服务器不支持 SMTP AUTH 扩展 - 尝试通过 Django 发送电子邮件
问题描述
我有一个 Docker 容器,我试图通过 Django 发送电子邮件。
我在另一个域上有一个单独的电子邮件服务器,我想将其用于此目的。我有其他应用程序可以毫无问题地连接它。
我的 Django 生产电子邮件设置如下所示(我打算将来用 Kubernetes 机密替换用户名和密码,但为了测试我只是将它们放在文件中):
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'mail.mydomain.io'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = "<username>"
EMAIL_HOST_PASSWORD = "<password>"
在我的模块中,我有以下代码:
from rest_framework.views import APIView
from django.core.mail import send_mail
class MailView(APIView):
def post(self, request):
subject = request.data.get("subject")
message = request.data.get("message")
sender = request.data.get("sender")
receipients = request.data.get("receipients")
send_mail(subject,message,sender,receipients,fail_silently=False,)
... more
这在本地工作,但是当我尝试在容器内运行它时,我收到以下错误:
smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server.
我是否需要在我的 Docker 容器中安装某种 SMTP 中继或服务器?
我的 Docker 容器基于python:3.7
容器,我目前没有安装任何 SMTP 扩展或任何东西。
解决方案
EMAIL_USE_TLS
需要设置为True
EMAIL_USE_TLS = True
推荐阅读
- ruby - 如何使用 ruby on rails 声明一个动态数组
- ios - iOS 目标 c 中的 NFC 标签阅读器错误消息“不支持功能”
- ios - AVCaptureMultiCamSession 前后图像 iOS
- tailwind-css - Tailwind CSS:有没有办法定位下一个兄弟姐妹?
- c++ - 如何在 C++ 中读取 EDB 文件
- java - 通过 DWA 从 DOORS 导出 ReqIF
- c++ - 哪些 C++ 对象(标准类型或 STYL)不能复制分配给另一个相同类型的对象?
- qt5 - 可检查的工具按钮图标颜色更改
- java - 即使文件有内容,readLine() 也会返回 null
- java - 一起使用 social_share 和 social_share_plugin 时 Flutter 应用程序崩溃