Testing Email in Django The Easy Way
Today a coworker showed me a very easy way to test django code that sends emails. It’s straight from the documentation:
Another approach is to use a “dumb” SMTP server that receives the e-mails locally and displays them to the terminal, but does not actually send anything. Python has a built-in way to accomplish this with a single command:
python -m smtpd -n -c DebuggingServer localhost:1025This command will start a simple SMTP server listening on port 1025 of localhost. This server simply prints to standard output all e-mail headers and the e-mail body. You then only need to set the EMAIL_HOST and EMAIL_PORT accordingly, and you are set.
Tags: django, python, software, testing, tools, web applications
January 26th, 2010 at 12:48 am
Great! I was just having this problem. I was just uploading the whole project to my server every time I wanted to test it. Thanks, Tim!
March 6th, 2010 at 2:22 pm
Thanks for this post. I am new at django and this will help a lot.