Eureka moments in Python

Sion Arrowsmith siona at chiark.greenend.org.uk
Tue Mar 20 12:07:52 EDT 2007


Sion Arrowsmith  <siona at chiark.greenend.org.uk> wrote:
>This is more a "batteries included" eureka moment than a Python one,
>but writing a fetchmail substitute in 6 lines was an eye-opener.

On Fri, Mar 16, 2007 at 01:23:14PM -0500, someone emailed:
[This is a newsgroup/mailing list -- potentially useful information
like this should be shared, not taken to private email.]
> Would you mind sharing your fetchmail substitute code with me?  I'm
> curious to know what that looks like.

Unfortunately, I threw it away, as it was so trivial and I only needed
a one-shot solution. I kept meaning to come back to it and add some
configurability and error checking and such (and most importantly
providing an envelope From), but never did. The general idea is to
take the POP3 example from the library reference
(http://docs.python.org/lib/pop3-example.html) and replace the inner
for loop with "smtplib.SMTP('localhost').sendmail('', 'user',
'\n'.join(M.retr(i+1)[1]))"

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
  ___  |  "Frankly I have no feelings towards penguins one way or the other"
  \X/  |    -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list