Take the 2-minute tour ×

I am developing a django application on my MAC. The development server that comes with django is great. However, I installed the django-authopenid (combines django-registration app with openID) which follows the 3 step process: user signs up, app sends a confirmation email with link, and user clicks on link to confirm sign-up.

Since the django development server does not have a mail server, how do I test this confirmation email portion of the process? I followed an idea to print out the contents of the email to the terminal, but I can't follow the link. Any suggestions?

share|improve this question
add comment

4 Answers

Python has a debugging mail server available for this purpose.

Just execute this command and you'll have a mailserver running at port 1025

python -m smtpd -n -c DebuggingServer localhost:1025

After that you'll need to change your MAIL_HOST setting in Django and you can test your emails locally :)

share|improve this answer
ok, so I am running this, but I the link from the email throws an error. The link is: <a href=3D"openid-example.e-engura.org/account/activate/e29864d921cd= 1455e63a150e6ea122adbbe4a158/">/account/activate/e29864d921cd1455e63a150e6e= a122adbbe4a158/</a>. –  rich Sep 17 '10 at 0:22
Do I need to change this somewhere. Thanks. –  rich Sep 17 '10 at 0:23
That link is generated with the sites framework. In the Django admin you can change the site url to something that will work (like localhost:8000) –  Wolph Sep 17 '10 at 0:25
I changed it in the 'activation_email.txt' file that is used to generate the email. Thanks again! –  rich Sep 17 '10 at 0:43
The changes to settings.py (or settings_local.py if you have that configured) are: EMAIL_HOST = "localhost" EMAIL_PORT = 1025 –  newz2000 May 24 '12 at 22:54
add comment

If you have a Gmail account, you can use it to send your dev mail. Put the following in your settings.py file:

# django-registration
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'YourEmail@gmail.com'
EMAIL_HOST_PASSWORD = 'YourGmailPassword'
DEFAULT_FROM_EMAIL = 'DevBox <YourEmail@gmail.com>'
share|improve this answer
add comment

The following additions to settings.py will make it so all emails sent by your django apps are written to <PROJECT_ROOT>/dev/email/ (or choose another directory):

# I put this at the top of all my settings.py files
import os
ROOT = os.path.dirname(os.path.abspath(__file__))

# Somewhere later
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = path(ROOT, "dev", "email")
share|improve this answer
add comment

I personally love django-extensions (https://github.com/django-extensions/django-extensions)

It adds a manage.py command called 'mail_debug' that does what WoLpH recommended automatically.

It also comes with a ton of other great debugging and dev tools like runserver_plus, show_template, show_urls, etc... (I really wish django-extensions would get rolled into Django already!)

share|improve this answer
add comment

Your Answer


