6 ms·
Sending Emails Through Python and GMail
- hnriot 14y agoI don't understand how that can take more than two hours of someone who's a college senior (presuming you're a CS student). This is just a handful of lines of very simple python using one of the most documented and oldest web protocols. There's also a ton if similar examples online using php, java, etc. that should have taken more like ten minutes to write.
- cardamomo 14y agoI wrote a very similar script several months ago, and it also took me longer than it should have. What kept me from doing it quickly was this nagging voice in the back of my mind telling me that there must be a better way to send a message through Gmail. (Or that I was somehow violating Gmail's TOS.)
- rjzzleep 14y agoit's funny you say that, because i find it funny that you assume it takes a cs student to build that. did we really dumb down so much that we're having problems using smtp libraries nowadays? i don't think so.
- goostavos 14y agoI'm currently a CS student, I'd argue that 2/3 of my class -- of not more! -- would need way more than two hours to accomplish the same 10 lines of code. There exists a type of CS student that doesn't really seem to enjoy programming all that much -- if at all. They do the minimum required to nail that passing grade, and then never type another line until the next assignment. Thus, when they actually need to pull on some of those tools (like sending some mail), they aren't there. Not that this guy is one of those, but I'm just saying, they exist, and in alarming numbers.
- SimHacker 14y agoA good CS student spends some time up front reading all the source code of the libraries they're using, and some code that uses the libraries, to know what they're really doing, what they're capable of, and to learn from them. And by CS student, I include life-long students, and self-taught students.
- celer 14y agoI don't think that the code needs a CS student. A programmer, perhaps. But a motivated high school freshman with prior python experience can figure this out, given some time.
- drivebyacct2 14y agoI'm just guessing here, but maybe the author didn't: know that email had a standard protocol, didn't know that gmail implemented, didn't find an exact sample (sometimes I get stuck on something and need a better example to understand an [harder] API)?
- d0mine 14y agoExcept it seems it doesn't support non-ascii characters in subject and body, server certificate is not checked. Also should From be escaped escaped or line lengths be limited? If message header, body is generated using email package e.g., [1] then it is not necessary to think about it. [1]: http://stackoverflow.com/a/12550481 http://stackoverflow.com/a/12550481
- kenneth_reitz 14y agoThis is a perfect example of why I dropped out of my CS program one year in: The most proficient of students had no idea what they were doing.
- deleted 14y ago[deleted]
- lh7777 14y agoI've been using script similar to this for years: http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-with-python.html http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-...
- jc4p 14y agoIf anyone cares (or doesn't want to waste a few hours learning) about how to do the flip side, here's how to read Gmail using Python: https://github.com/jc4p/google-voice-twitter-messenger/blob/master/email_checker.py#L8 https://github.com/jc4p/google-voice-twitter-messenger/blob/...
- cyansmoker 14y agoYou can also look at how it's done in the Mezzanine network (disclaimer: I am a minor contributor)
- raphman 14y agoHere's a similar script for sending customized emails to multiple recipients defined in a CSV file (without MIME/attachment support). https://github.com/RaphaelWimmer/csv_mailer/blob/master/csv_mailer.py https://github.com/RaphaelWimmer/csv_mailer/blob/master/csv_...