If your tests extends from django.test.testcases.TestCase then nothing has to be done. Django will replace the EmailBackend to a "special" one. Then you can test what would had been sent like this :
def testMethodThatSendAEmail(self):
...
from django.core import mail
object.method_that_send_email(to='me@example.com')
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].to, ['me@example.com'])
...#etc
The outbox object is a special object that get injected into mail when
python manage.py test is run.
This elaborates on the answer from Benjamin. One way that I test emails if I don't have a local email server like postfix, sendmail or exim installed is to run the python email server. You can run it on port 25 with sudo, or just use a port > 1024 (reserved ports):
Now test out your emails, or you can do this in ./manage.py shell in another terminal window like so:
python manage.py shell
And paste in this code to send an email:
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', 'messanger@localhost.com',['any@email.com'], fail_silently=False)
No need to use any real emails since you will see everything in your terminal. You can dump it to the appropriate container like .html for further testing.