One of the ways I've decided in the past is to use qmail .qmail files ( docs ).
Basically, you set up qmail and enter your email address (for convenience, assume that proc@whatever.com is your email address) in your home directory. In this directory, you create a .qmail-proc file to process mail.
This allows you to use a full-fledged SMTP server on your server, including spam filtering, forwarding, aliases, all these funny things. You can then transfer the data from the email to the application. In your case, I would suggest making a Mangement Command in Django to handle email (I will call it proc_email ). So your .qmail-proc might look like this:
/var/spool/mail/proc | /www/django/myproject/manage.py proc_email
This is where a copy of the email message is stored in /var/spool/mail/proc , and then an email is sent to the script in the second line. The message itself is sent to proc_email via sys.stdin . Just read the letter from there and save it through your Django models.
If you need to process emails for different addresses later, you can also set up aliases pointing to your home directory and use .qmail-<username> files for each alias. Allow you to pass other flags (e.g. username for each alias) to proc_email if necessary.
I should point out that this is not the easiest solution, but it can scale and is pretty damn proof of a bullet.
source share