我是django的新手,可以通过做一个房地产网站来学习django的课程,在该网站中,用户可以查询每个网站中显示的每个网站。在这里,我想以此发送电子邮件,并且按照我正在关注的视频教程中的说明进行操作,并编写了如下代码 我的settings.py是
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER='glakshmi@gmail.com'
EMAIL_HOST_PASSWORD='1@st345'
EMAIL_USE_TLS=True
在views.py
# Send email
send_mail(
'Property Listing Inquiry',
'There has been an inquiry for ' + listing + '. Sign into the admin panel for more info',
'glakshmi@gmail.com', # This is the from email address
[realtor_email, 'glakshmi.nyros@gmail.com'], # This is to email address means we are specifiying where should the email goes
fail_silently=False
)
messages.success(request, 'Your request has been submitted, a realtor will get back to you soon')
return redirect('/listings/'+listing_id)
答案 0 :(得分:0)
确保帐户密码正确,并通过gmail正确设置了权限:
https://support.google.com/accounts/answer/6010255?hl=en https://stackoverflow.com/a/36532619/1021294
答案 1 :(得分:0)
记住:
转到您的Google帐户设置,找到安全性->帐户权限->访问不太安全的应用,启用此选项。