5

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='ant@a.com'
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=['abc@gmail.com','def@gmail.com']

    send_mail(subject,message,'ant@a.com',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?

divibisan
  • 11,659
  • 11
  • 40
  • 58
Nishant Kumar
  • 81
  • 1
  • 7
  • 1
    Where are you importing `send_mail` from? The error says that the function you’re calling doesn’t expect `fail_silently` parameter so either you’re importing the wrong `send_mail` or you haven’t read the documentation correctly for the `send_mail` you’re using. What’s your email backend? – dirkgroten Jan 29 '19 at 07:55

3 Answers3

1

sent_mail() function maybe overridden

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 14 '22 at 15:37
0
from django.core.mail import EmailMessage

def testemail(request):
  subject="test email"
  message="hello sid"
  reply_to_list=['abc@gmail.com','def@gmail.com']

  email = EmailMessage(subject,message,'ant@a.com',reply_to_list)
  email.send(fail_silently=True)
-2

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.