From a44d6d87d939f1e25c17653837823a38a4d68b34 Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Tue, 22 Jan 2013 20:44:46 -0800 Subject: [PATCH] Moving piped documentation into same section as polling. --- docs/index.rst | 2 +- docs/topics/piped.rst | 59 ----------------------------------- docs/topics/polling.rst | 68 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 64 deletions(-) delete mode 100644 docs/topics/piped.rst diff --git a/docs/index.rst b/docs/index.rst index 199c865..9a3a5e8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,7 +18,7 @@ the e-mail will be stored, and you can process it at will (or, if you're in a hu Contents: .. toctree:: - :maxdepth: 2 + :maxdepth: 3 :glob: topics/* diff --git a/docs/topics/piped.rst b/docs/topics/piped.rst deleted file mode 100644 index 75f1903..0000000 --- a/docs/topics/piped.rst +++ /dev/null @@ -1,59 +0,0 @@ - -Receiving mail directly from Exim4 or Postfix via a pipe -======================================================== - -Django Mailbox's ``processincomingmessage`` management command accepts, via ``stdin``, incoming messages. -You can configure Postfix or Exim4 to pipe incoming mail to this management command -to import messages directly without polling. - -You need not configure mailbox settings when piping-in messages, -mailbox entries will be automatically created matching the e-mail address to which incoming messages are sent, -but if you would like to specify the mailbox name, -you may provide a single argument to the ``processincmingmessage`` command -specifying the name of the mailbox you would like it to use (and, if neccessary, create). - -Receiving Mail from Exim4 -------------------------- - -To configure Exim4 to receive incoming mail, -start by adding a new router configuration to your Exim4 configuration like:: - - django_mailbox: - debug_print = 'R: django_mailbox for $localpart@$domain' - driver = accept - domains = +local_domains - transport = send_to_django_mailbox - local_parts = emailusernameone : emailusernametwo - -Make sure that the e-mail addresses you would like handled by Django Mailbox are not handled by another router; -you may need to disable some existing routers. - -Change the contents of ``local_parts`` to match a colon-delimited list of usernames for which you would like to receive mail. -For example, if one of the e-mail addresses targeted at this machine is ``jane@example.com``, -the contents of ``local_parts`` would be, simply ``jane``. - -Next, a new transport configuration to your Exim4 configuration:: - - send_to_django_mailbox: - driver = pipe - command = /path/to/your/environments/python /path/to/your/projects/manage.py processincomingmessage - user = www-data - group = www-data - return_path_add - delivery_date_add - -Like your router configuration, transport configuration should be altered to match your environment. -First, modify the ``command`` setting such that it points at the proper python executable -(if you're using a virtual environment, you'll want to direct that at the python executable in your virtual environment) -and project ``manage.py`` script. -Additionally, you'll need to set ``user`` and ``group`` such that -they match a reasonable user and group (on Ubuntu, ``www-data`` suffices for both). - -Receiving mail from Postfix ---------------------------- - -Although I have not personally tried using Postfix for this, -Postfix is capable of delivering new mail to a script using ``pipe``. -Please consult the `Postfix documentation for pipe here `_. -You may want to consult the above Exim4 configuration for tips. - diff --git a/docs/topics/polling.rst b/docs/topics/polling.rst index 45f8ec7..ee733d3 100644 --- a/docs/topics/polling.rst +++ b/docs/topics/polling.rst @@ -1,6 +1,6 @@ Getting incoming mail ---------------------- +===================== If you are utilizing one of the polling methods above, you will need to periodically poll the mailbox for messages using one of the below methods. @@ -9,21 +9,81 @@ If you are receiving mail directly from a mailserver via a pipe you need not concern yourself with this section. In your code -............ +------------ Mailbox instances have a method named ``get_new_mail``; this method will gather new messages from the server. Using the Django Admin -...................... +---------------------- Check the box next to each of the mailboxes you'd like to fetch e-mail from, and select the 'Get new mail' option. Using a cron job -................ +---------------- You can easily consume incoming mail by running the management command named ``getmail`` (optionally with an argument of the name of the mailbox you'd like to get the mail for).:: python manage.py getmail + + +Receiving mail directly from Exim4 or Postfix via a pipe +-------------------------------------------------------- + +Django Mailbox's ``processincomingmessage`` management command accepts, via ``stdin``, incoming messages. +You can configure Postfix or Exim4 to pipe incoming mail to this management command +to import messages directly without polling. + +You need not configure mailbox settings when piping-in messages, +mailbox entries will be automatically created matching the e-mail address to which incoming messages are sent, +but if you would like to specify the mailbox name, +you may provide a single argument to the ``processincmingmessage`` command +specifying the name of the mailbox you would like it to use (and, if neccessary, create). + +Receiving Mail from Exim4 +......................... + +To configure Exim4 to receive incoming mail, +start by adding a new router configuration to your Exim4 configuration like:: + + django_mailbox: + debug_print = 'R: django_mailbox for $localpart@$domain' + driver = accept + domains = +local_domains + transport = send_to_django_mailbox + local_parts = emailusernameone : emailusernametwo + +Make sure that the e-mail addresses you would like handled by Django Mailbox are not handled by another router; +you may need to disable some existing routers. + +Change the contents of ``local_parts`` to match a colon-delimited list of usernames for which you would like to receive mail. +For example, if one of the e-mail addresses targeted at this machine is ``jane@example.com``, +the contents of ``local_parts`` would be, simply ``jane``. + +Next, a new transport configuration to your Exim4 configuration:: + + send_to_django_mailbox: + driver = pipe + command = /path/to/your/environments/python /path/to/your/projects/manage.py processincomingmessage + user = www-data + group = www-data + return_path_add + delivery_date_add + +Like your router configuration, transport configuration should be altered to match your environment. +First, modify the ``command`` setting such that it points at the proper python executable +(if you're using a virtual environment, you'll want to direct that at the python executable in your virtual environment) +and project ``manage.py`` script. +Additionally, you'll need to set ``user`` and ``group`` such that +they match a reasonable user and group (on Ubuntu, ``www-data`` suffices for both). + +Receiving mail from Postfix +........................... + +Although I have not personally tried using Postfix for this, +Postfix is capable of delivering new mail to a script using ``pipe``. +Please consult the `Postfix documentation for pipe here `_. +You may want to consult the above Exim4 configuration for tips. +