Hacker News new | comments | show | ask | jobs | submit login
Sending Emails Through Python and GMail (jmduke.net)
24 points by carlobundy 1575 days ago | hide | past | web | 13 comments | favorite

If 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/...

I've been using script similar to this for years: http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-...

Here's a similar script for sending customized emails to multiple recipients defined in a CSV file (without MIME/attachment support).


I 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.

I 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.)

Except 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

This 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.

it'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.

I'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.

A 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.

I 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.

I'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)?

You can also look at how it's done in the Mezzanine network (disclaimer: I am a minor contributor)

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact