[Django]-Verify mail was sent from unit tests

45👍

The latest Django testing documentation has an Email Services section.

Then you just do something like:

from django.core import mail

print mail.outbox[0].body

The HTML version is handled via attached alternative mimetypes, which you can access (if you attached one) such as

content, mimetype = mail.outbox[0].alternatives[0]

Outbox objects are EmailMessages, further documented here

Leave a comment