在 python 中发送不同域名的邮件

sending mails with different domain names in python

我在发送不同域名的邮件时收到 "SMTP AUTH extension not supported by server"。 例如,我使用 person@example.com 发送邮件。我的域名是 example.com.

当我尝试发送邮件时收到 "SMTP AUTH extension not supported by server" 错误

这是我的代码

settings.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.somedomain.com'
EMAIL_HOST_USER = 'Admin@somedomain.com'
EMAIL_HOST_PASSWORD = '***********'
EMAIL_PORT = 25
EMAIL_USE_TLS = True

views.py

msg = "Hi,this is testing mail."
try:
    send_mail('Appointment mail',msg,'',['user@somedomain.com'])
    response = 'Message sent successfully.You will receive response in very soon.Thank you.' 
except Exception as e:
    response = e
return HttpResponse(response)

任何人都可以帮助我,在此先感谢!

我认为这可以帮助你。 Getting 'str' object has no attribute 'get' in Django。您不能直接 return 'str' 作为回应。您需要 HttpResponse

from django.http import HttpResponse
return HttpResponse(response)

希望对您有所帮助。