<p>I am writing a web application that requires user interaction via email.  I'm curious if there is a best practice or recommended source for learning about processing email.  I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for automated processing.  I'm also looking for guidance on processing bouncebacks.  </p>

[{'answer_id': 79670, 'author': 'Jerub', 'author_id': 14648, 'author_profile': 'https://Stackoverflow.com/users/14648', 'pm_score': 3, 'selected': True, 'text': '<p>There are some pretty serious concerns here for how to send email automatically, and here are a few:</p>\n\n<p>Use an email library. Python includes one called \'email\'. This is your friend, it will stop you from doing anything tragically wrong. Read an example from <a href="http://docs.python.org/lib/node161.html" rel="nofollow noreferrer">the Python Manual</a>.</p>\n\n<p>Some points that will stop you from getting blocked by spam filters:</p>\n\n<p>Always send from a valid email address. You must be able to send email to this address and have it received (it can go into /dev/null after it\'s received, but it must be possible to /deliver/ there). This will stop spam filters that do Sender Address Verification from blocking your mail.</p>\n\n<p>The email address you send from on the server.sendmail(fromaddr, [toaddr]) line will be where bounces go. The From: line in the email is a totally different address, and that\'s where mail will go when the user hits \'Reply:\'. Use this to your advantage, bounces can go to one place, while reply goes to another.</p>\n\n<p>Send email to a local mail server, I recommend postfix. This local server will receive your mail and be responsible for sending it to your upstream server. Once it has been delivered to the local server, treat it as \'sent\' from a programmatic point of view.</p>\n\n<p>If you have a site that is on a static ip in a datacenter of good reputation, don\'t be afraid to simply relay the mail directly to the internet. If you\'re in a datacenter full of script kiddies and spammers, you will need to relay this mail via a public MTA of good reputation, hopefully you will be able to work this out without a hassle.</p>\n\n<p>Don\'t send an email in only HTML. Always send it in Plain and HTML, or just Plain. Be nice, I use a text only email client, and you don\'t want to annoy me.</p>\n\n<p>Verify that you\'re not running SPF on your email domain, or get it configured to allow your server to send the mail. Do this by doing a TXT lookup on your domain.</p>\n\n<pre><code>$ dig google.com txt\n...snip...\n;; ANSWER SECTION:\ngoogle.com.     300 IN  TXT "v=spf1 include:_netblocks.google.com ~all"\n</code></pre>\n\n<p>As you can see from that result, there\'s an SPF record there. If you don\'t have SPF, there won\'t be a TXT record. Read more about <a href="http://en.wikipedia.org/wiki/Sender_Policy_Framework" rel="nofollow noreferrer">SPF on wikipedia</a>.</p>\n\n<p>Hope that helps.</p>\n'}, {'answer_id': 79743, 'author': 'NotMe', 'author_id': 2424, 'author_profile': 'https://Stackoverflow.com/users/2424', 'pm_score': 2, 'selected': False, 'text': '<p>Some general information with regards to automated mail processing...</p>\n\n<p>First, the mail server "brand" itself isn\'t that important for broadcasting or receiving emails.  All of them support the standard smtp / pop3 communications protocol. Most even have IMAP support and have some level of spam filtering.  That said, try to use a current generation email server.</p>\n\n<p>Second, be aware that in an effort to reduce spam a lot of the receiving mail servers out there will simply throw a message away instead of responding back that a mail account doesn\'t exist.  Which means you may not receive those.</p>\n\n<p>Bear in mind that getting past spam filters is an art.  A number of isp\'s watch for duplicate messages, messages that <em>look</em> like spam based on keywords or other content, etc.  This is sometimes independent of the quantity of messages sent; I\'ve seen messages with as few as 50 copies get blocked by AOL even though they were legitimate emails.  So, testing is your friend and look into <a href="http://en.wikipedia.org/wiki/Anti-spam_techniques_(e-mail)" rel="nofollow noreferrer">this article on wikipedia</a> on anti-spam techniques.  Then make sure your not doing that crap.</p>\n\n<p>**</p>\n\n<p>As far as processing the messages, just remember it\'s a queued system.  Connect to the server via POP3 to retrieve messages, open it, do some action, delete the message or archive it, and move on.</p>\n\n<p>With regards to bouncebacks, let the mail server do most of the work.  You should be able to configure it to notify a certain email account on the server in the event that it is unable to deliver a message.  You can check that account periodically and process the Non Delivery Reports as necessary.</p>\n'}]
['https://Stackoverflow.com/questions/79602', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/322887/']