views:

50

answers:

4

I have a Django application running locally and I'd like to test the "send_mail()" functionality. Currently, I'm able to turn on postfix using the following command in Terminal:

sudo postfix start

Once I turn on postfix, I run the following command in Terminal:

telnet localhost 25

Those two steps seem to be working because the "send_mail()" function does not fail or result in an exception. Unfortunately, I'm not sure what I should do next to see the emails it's sending. I tried to configure Mail.app to connect to localhost, but no such luck.

Does anyone have insight into what I need to do next to see the emails that postfix is sending?

+1  A: 

Have a look at postfix's log, or the mail queue. If the messages are building up in the queue, then the next thing to do is to configure your postfix to forward messages on to remote MTAs...which is a serverfault.com question ;).

Graham Lee
+4  A: 

you could try using the django email test server?

see the docs at http://docs.djangoproject.com/en/dev/topics/email/#testing-e-mail-sending

emails will just be listed as you send them.

Jameso
Ha...maybe I should finish ready the entire page next time. This works well enough for my purposes. Thanks!
Huuuze
+2  A: 

Postfix will try to deliver the mails to the system you named. This may fail for various reasons, such as:

  1. The address doesn't exist.
  2. The remote mailserver rejected it.
  3. Your ISP blocks port 25 outbound so postfix can't deliver anything.

You can see queued mails with the sendmail alias mailq (need to be sudo). Postfix also keeps detailed logs in /var/log

If you are sending to @localhost, you need to also setup a POP3 or IMAP server on your system for Mail.app to be able to read e-mail. Without using Mail.app, you can find the system mail spool (/var/mail is a common spot).

Yann Ramin
+1  A: 

The email test server is great, but it's hard to preview html email at all. Shameless plug, but I've developed an app to help with it.

Add it to your INSTALLED_APPS and point the EmailBackend to it, and you're done. Emails will be stored up on the database and in the admin you can view them, including HTML multi parts.

Arthur Debert