I have a Docker container where I am trying to send an email via Django.
I have a separate email server on another domain that I want to use for this purpose. I have other applications connect with it with no problem.
My Django production email setup looks like this (I intend to replace username and password with Kubernetes secrets in the future, but for testing I am just putting them inside the file):
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>"
In my module, I have the following code:
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
This works locally, however when I try to run it inside the container, I get the following error:
smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server.
Do I need to install some sort of SMTP relay or server to my Docker container?
My Docker container is based on the python:3.7
container and I am not currently installing any SMTP extensions or anything to it.
EMAIL_USE_TLS
needs to be set to True
EMAIL_USE_TLS = True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.