4 ms·
I'm guessing this is not complete? I'll review it like it is complete though, since it doesn't say anywhere if it is or not. I hope no one uses this in produc
by illumen 14y ago
I'm guessing this is not complete? I'll review it like it is complete though, since it doesn't say anywhere if it is or not.
I hope no one uses this in production. Handling SMTP well is all about the edge cases, and this doesn't seem to handle any of them.
This is just a thin wrapper on python stdlib smtpd.SMTPServer, which is itself not production ready. It also doesn't really make it easier. The original API is better. Why are magic decorators better than inheritance again?
Also, monkey patching? Hidden side effects make sad pandas cry. Let me throw up a little in my mouth.
There are zero unit tests for this, and no functional tests.
The original API has better documentation. What are the to, sender, and body arguments?
Below seems a simpler API, and gives you the subject too. I thought humans would be interested in the subject... but I guess not.
import inbox
for m in inbox:
toprint = m.to, m.from, m.subject, m.body
print ("to:{} from:{} subject:{} body:{}".format(toprint))
- mmerickel 14y agoI don't understand why the library chooses to require gevent. That's a large dependency for an API that might be useful otherwise. That should really be up to the user since it looks like it'd work fine in its own thread or standalone.
- jonknee 14y agoIt's to monkey patch the socket code of smtpd to make it async. Apparently that nets a nifty speed bump: > "One instance should handle over one thousand emails per second, thanks to Gevent." Take a look at the code, it's very small.
- seanp2k2 14y agoSeconded. Also, why re-invent the wheel? You're not DJB, an even if you were, qmail kinda sucks these days. With exim and postfix already out there...I'm struggling to see a point to this. Want your app to send some mail? Please please please don't try delivering directly. The only people great at this are spammers. Use a real MTA and the mail() function that is built into basically every language.
- idonthack 14y agoThis is less re-inventing the wheel and more putting a square tire on it
- kenneth_reitz 14y agoThis is for receiving mail.
- kenneth_reitz 14y agoIt's quite production ready. I wrote some very similar that has been in production and used by thousands of people for months. SMTP does have many edge cases, and if you're interested in handling all of them, you should use a more robust server. I am not.
- RyanMcGreal 14y agoIt looks simple and elegant. Can you recommend something equally simple, elegant and freestanding to send email in Python?
- shazow 14y agoYou're right, it's a trivial wrapper with a subjective/opinionated usability improvement. I think the biggest service here is 1. Education about Python's pretty decent standard smtpd lib. 2. Food for thought about making thin custom interfaces over standard libraries. 3. Perhaps inspiration to do more? It's no Linux kernel, but I enjoyed reading through the source and I feel like I have a better understanding of Python's smtpd lib and I've some of my own ideas for future API design. Additionally, I like your generator-based API proposal. Also inspiring. Need to think more about routing in that context, though.
- TylerE 14y agoMuch easier to sneer than get stuff done, isn't it?
- illumen 14y agoTroll.