How to configure nginx to serve mail for django

1,090 views
Skip to first unread message

Chris Pagnutti

unread,
Nov 12, 2012, 1:22:38 PM11/12/12
to django...@googlegroups.com
Hi.  I'm using nginx+uwsgi to serve a django app.  I'd like to configure it to be able to send mail with django's send_mail() and send_mass_mail() functions.  I've played with the nginx configuration files using the examples here

I have a very simple view that just does 
from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'fr...@example.com',
    ['t...@example.com'], fail_silently=False)

but with my email addresses in there of course.  The view doesn't throw any exceptions, but it also doesn't send the email (or do anything else for that matter).  Can someone help me with getting nginx to serve email for django, or at least point me in the right direction?  Thanks to all.

Nikolas Stevenson-Molnar

unread,
Nov 12, 2012, 1:46:03 PM11/12/12
to django...@googlegroups.com
The nginx configuration examples you link to are all POP3 or IMAP. Sending mail is SMTP. But even then, you need an SMTP server to proxy to. In these examples, nginx is simply acting as a proxy, not as an actual mail server. I would recommend using a bona fide SMTP server. Or use one already available to you from your mail provider (e.g., if you use GMail, you can configure Django to use GMail's mail servers to send email).

_Nik
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/yfrTK_xhMpUJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Chris Pagnutti

unread,
Nov 12, 2012, 3:51:57 PM11/12/12
to django...@googlegroups.com
Yeah.  Makes good sense.  I guess that Postfix is one of the more popular options.  Is there any reason why I should NOT use postfix.
Message has been deleted

Chris Pagnutti

unread,
Nov 12, 2012, 8:48:04 PM11/12/12
to django...@googlegroups.com
Not sure.  It's VPS and I was handed a Debian install with practically nothing on it.  I even had to install make to be able to compile nginx.  I'm looking into setting up Postfix+Dovecot+Roundcube (or SquirrelMail)

On Mon, Nov 12, 2012 at 8:37 PM, Dennis Lee Bieber <wlf...@ix.netcom.com> wrote:
On Mon, 12 Nov 2012 12:51:57 -0800 (PST), Chris Pagnutti
<chris.p...@gmail.com> declaimed the following in
gmane.comp.python.django.user:


> Yeah.  Makes good sense.  I guess that Postfix is one of the more popular
> options.  Is there any reason why I should NOT use postfix.
>
        Well, do you already have access to a running SMTP daemon? (Does
your server machine respond to local connection attempts on port 25? Is
the server machine part of a network that may have an SMTPd located on
another machine?
).
--
        Wulfraed                 Dennis Lee Bieber         AF6VN
        wlf...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
Message has been deleted

Chris Pagnutti

unread,
Nov 14, 2012, 2:41:11 PM11/14/12
to django...@googlegroups.com, wlf...@ix.netcom.com
Good point.  At the moment, sending mail is my priority, but eventually I'll want to receive and view mail as well.  Most guides I can find relate to setting up both sides of the story, so I figure I might as well just do it all at once.

On Tuesday, November 13, 2012 2:39:11 PM UTC-5, Dennis Lee Bieber wrote:
On Mon, 12 Nov 2012 20:48:04 -0500, Chris Pagnutti
<chris.p...@gmail.com> declaimed the following in
gmane.comp.python.django.user:

> Not sure.  It's VPS and I was handed a Debian install with practically
> nothing on it.  I even had to install make to be able to compile nginx.
>  I'm looking into setting up Postfix+Dovecot+Roundcube (or SquirrelMail)
>

        As I recall, your problem was to SEND mail. From a quick Google
session, Dovecot and Roundcube are not products for sending mail --
Dovecot being a POP3/IMAP server and Roundcube a web-mail interface.
Were you planning on hosting /mailboxes/ for users?

        Postfix (alternatively, Sendmail, qmail, exim -- though qmail has
fallen behind in features) is the only item in the list needed to send
email /out/.  {If I recall, it would also be used to receive mail sent
to your server, and /that/ would then need to be placed into a local
account mailbox -- you may need a POP3/IMAP server if you want to later
read those [presuming the only inbound is stuff for the sysop:
postm...@xxxx.xxx, ad...@xxxx.xxx, something like that] without SSH
into the server environment}.

{Hmmm, http://en.wikipedia.org/wiki/Exim implies the default SMTPd for
Debian is exim}
Message has been deleted

Chris Pagnutti

unread,
Nov 14, 2012, 7:18:21 PM11/14/12
to django...@googlegroups.com
Webmail function as a django application = Totally awesome idea.

I'll probably need some other email addresses for non-administrator users, so a friendly client would be nice.  Roundcube should do the trick for now, but integrating the webmail into the django app itself would be rad.



On Wed, Nov 14, 2012 at 4:37 PM, Dennis Lee Bieber <wlf...@ix.netcom.com> wrote:
On Wed, 14 Nov 2012 11:41:11 -0800 (PST), Chris Pagnutti

<chris.p...@gmail.com> declaimed the following in
gmane.comp.python.django.user:
> Good point.  At the moment, sending mail is my priority, but eventually
> I'll want to receive and view mail as well.  Most guides I can find relate
> to setting up both sides of the story, so I figure I might as well just do
> it all at once.
>

        Well... The SMTP daemon should also handle the "receive" part; if
properly configured with local user account mailboxes... (pre-spam era
one could connect to any SMTPd to transfer mail; mail didn't have to
either come from an internal user account or be sent to a local user
account -- these days, that would be considered an open relay)

        I presume you have some sort of shell access to the server since you
are doing configuration. Basic shell mail clients didn't* need POP3;
they directly access the mailbox(es) on the machine itself. So if your
intent is purely to receive mail being sent to /you/ as administrator of
the server, you may not need the POP3/IMAP/Webmail stuff. Those
protocols are meant for when the server is used to store emails that
will be accessed from other computers at ad-hoc intervals. Since this is
a Django group -- have you considered making the webmail function a
Django application?



* It's been too many years, but the first mail client I used on my old
Amiga ONLY knew how to read a mailbox (AmigaElm); sending email invoked
a subprocess that took the composed mail and submitted it to a queue
directory -- it knew nothing about SMTP or POP3. I had to run a
simplified SMTP to process the outgoing queue, and a timed job to do
POP3 fetching into the mailbox. My first real Python program was to
create an outgoing SMTPd, because the two packages I'd tried had flaws
(one would block if it couldn't get to a destination host, the other
never sent to CC/BCC addresses).

--
        Wulfraed                 Dennis Lee Bieber         AF6VN
        wlf...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
Reply all
Reply to author
Forward
0 new messages