send_mail not filling mail.outbox in certain circumstance

17 views
Skip to first unread message

Matthew Pava

unread,
Jul 8, 2020, 10:55:21 AM7/8/20
to Django users
Good day,
I'm writing a functional test for checking that an email was sent after a record was revised in my project. I placed a print statement to verify that the send_mail function was called within the view that it is called in, and it prints it out at the appropriate time. However, when I check mail.outbox, the email is not in there--nothing is in there. I am using a class that inherits from StaticLiveServerTestCase, so I thought that should automatically handle changing the email setting appropriately. What am I missing?

I did try something else, though. Within the test function, I performed a dummy send_mail call, and mail.outbox was populated with the dummy message. But it is not populated with the message I want to test against. I appreciate any guidance you can offer in this matter.

Thanks,
Matthew

Matthew Pava

unread,
Jul 8, 2020, 12:01:21 PM7/8/20
to Django users
Well, I discovered that send_mail fails silently when you tell it not to. Apparently, I did not have the to_email and recipient_list populated with anything. I wonder if we could change the behavior of send_mail to require at least one of those two arguments...
Reply all
Reply to author
Forward
0 new messages