Search code examples
djangosmtplib

How to bypass current error in data tuple in send mass mail?


I am working on a bulk mailing platform using Django send_mass_mail function. Everything worked perfectly. But the problem I am facing is, I have nearly 500 recipients, and if one recipient fails to receive mail (recipient side errors like, improper mail address provision), the whole function stops immediately. How to send the next mail, if current data tuple has errors in data. I think the question is straight and need no code examples. Since i followed straight from the Django Docs


Solution

  • According to the docs you could use fail_silently=True (which is False by default):

    fail_silently: A boolean. When it’s False, send_mail() will raise an smtplib.SMTPException if an error occurs. See the smtplib docs for a list of possible exceptions, all of which are subclasses of SMTPException.