'Django getting error :send_mail() got an unexpected keyword argument 'fail_silently' on sending mails
I am new to django and trying to use django emailer. I have provided the following settings for mail in settings.py :
EMAIL_USE_TLS = True
EMAIL_HOST='smtp.gmail.com'
EMAIL_HOST_USER='[email protected]'
EMAIL_HOST_PASSWORD='******'
EMAIL_PORT = 587
I have defined one view in my views.py as following:
def testemail(request) :
subject="test email"
message="hello sid"
reply_to_list=['[email protected]','[email protected]']
send_mail(subject,message,'[email protected]',reply_to_list,fail_silently=True)
I have registered this view in url.py as:
url(r'^testemail/',email_views.testemail,name="testemail")
But after hitting the url I get the following error:
send_mail() got an unexpected keyword argument 'fail_silently'
Any idea why I'm getting this error?
Solution 1:[1]
from django.core.mail import EmailMessage
def testemail(request):
subject="test email"
message="hello sid"
reply_to_list=['[email protected]','[email protected]']
email = EmailMessage(subject,message,'[email protected]',reply_to_list)
email.send(fail_silently=True)
Solution 2:[2]
sent_mail() function maybe overridden
Solution 3:[3]
You must verify if your function name is send_mail too, because it do conflict with the send_mail call for send mail with.
So rename your function other than send_mail.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | wen tse yang |
| Solution 2 | Vishal Kumar |
| Solution 3 | Chany Fatal Ngoy |
