【发布时间】:2021-03-31 09:21:57
【问题描述】:
我正在一个项目中工作,我需要将电子邮件发送给在表单中填写电子邮件的用户。我可以使用我的Gmail Account 详细信息发送电子邮件,但同时使用outlook.365。 This is the image with error that I am getting.
我的要求是:
- 一旦用户进入注册表并填写详细信息,如姓名、电子邮件、手机
- 无论在表单中输入什么电子邮件,发送带有链接的电子邮件以创建新密码。
这是我的代码:
settings.py:
# Using outlook365:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST_USER = 'support@academic.com'
EMAIL_HOST = 'smtp.outlook.office365.com' # (also tried : smtp.office365.com and
outlook.office365.com)
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_PASSWORD = 'My_Password'
# Using my gmail account:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST_USER = 'admin@gmail.com'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_PASSWORD = 'My_Password'
views.py:
subject = "Academic - Create New Password"
message = "Hi %s! Please create your new Password here : http://127.0.0.1:8000/api/create-password" % firstname
send_mail(
subject, # Subject of the email
message, # Body or Message of the email
'support@academic.com', # from@gmail.com (admin@gmail.com for gmail account)
[email], # to@gmail.com # email that is filled in the form
)
请指导我使用 Outlook365 发送电子邮件需要哪些额外设置或配置。
【问题讨论】:
标签: python django django-rest-framework outlook rest