我有设置.py
# Email settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected] /cdn-cgi/l/email-protection'
EMAIL_HOST_PASSWORD = 'pass'
EMAIL_PORT = 587
电子邮件方法在 admin.py 中
send_mail(
'Subject here',
'Here is the message.',
'[email protected] /cdn-cgi/l/email-protection',
['[email protected] /cdn-cgi/l/email-protection'],
fail_silently=False,
)
但它给出了错误SMTP AUTH extension not supported by server.
我如何解决这个问题,在本地主机上工作
尝试创建一个像这样的自定义发送电子邮件文件
import smtplib
from email.message import EmailMessage
# Send Email Function
def send(to):
email = EmailMessage()
email['from'] = 'Test'
email['to'] = to
email['subject'] = 'Hello World'
with smtplib.SMTP(host='smtp.gmail.com', port=587) as smtp:
smtp.ehlo()
smtp.starttls()
smtp.login('user', 'password')
smtp.send_message(email)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)