'I am not able to send mail in django
THIS IS MY SETTINGS.PY FILE
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
DEFAULT_FROM_EMAIL= 'myyandexmail.com'
EMAIL_HOST = 'smtp.yandex.com'
EMAIL_HOST_USER = 'myyandexmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
This is my views.py file
def contact(request):
if request.method == "POST":
name = request.POST['name']
email =request.POST['email']
message =request.POST['message']
data = {
'name': name,
'email': email,
'message': message
}
done_message = 'Your message has been sent. We will respond to you soon'
try:
#send_mail(data['name'],data['message']+ '\n' ' from ' +
data['email'],'[email protected]',['[email protected]'],fail_silently=False)
msg=EmailMessage(data['name'],data['message']+ '\n' ' from ' +
data['email'],'myyandexmail.com',['myyandexmail.com'])
msg.send()
return render(request,'artgallery/contact.html',{'message':done_message})
except BadHeaderError:
return render(request,'artgallery/contact.html',{'message':done_message})
This is working file on lcoal host but doesnot work on digital ocean.First it was showing errors then i made changes to the code ..But it is not showing any errors now ..But it is not sending mails either...when i click the submit message button it only gets refreshed..What should i do..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
