newbie - POPLIB, MIMETOOLS and SMTPLIB - aaarrrghh!

Janko Hauser jhauser at ifm.uni-kiel.de
Mon Feb 19 12:37:31 CET 2001


"Andrew" <astuart at NO.mira.SPAMnet> writes:

> Hi there
> 
> sorry for being such a newbie.
> 
> In summary, I am trying to write a script which reads a POP mailbox,
> extracts the "subject" line from each message, and emails a message back to
> the sender, echoing the "subject" line.  Weird problems everywhere!
> 
> I can get POPLIB to read emails, but I can't get MIMETOOLS to read the
> emails - so there's no way for me to get the subject line out.
> I can get SMTPLIB to send emails, but I can;t work out how to include a
> subject line in the email.
> 
> I've looked for days throughout the Internet for solutions to these
> seemingly simple problems but I can't find anything.
> 
> Why would it be so hard for MIMETOOLS to read messages that come from
> POPLIB?  Surely they are designed to work together?
I'm not clear, why you want to use mimetools to read a plain email.

An example for this is included in the poplib.py file
        a = POP3(TESTSERVER)
        print a.getwelcome()
        a.user(TESTACCOUNT)
        a.pass_(TESTPASSWORD)
        a.list()
        (numMsgs, totalSize) = a.stat()
        for i in range(1, numMsgs + 1):
                (header, msg, octets) = a.retr(i)
                print "Message ", `i`, ':'
                for line in msg:
                        print '   ' + line
                print '-----------------------'
        a.quit()

If this does not work some more information about your errors would be
interesting.

> 
> Why so hard to include a subject line using SMTPLIB?
For an example with subject line try this

>>> s=smtplib.SMTP("localhost")
>>> print s.sendmail.__doc__

HTH,
__Janko

-- 
  Institut fuer Meereskunde             phone: 49-431-597 3989
  Dept. Theoretical Oceanography        fax  : 49-431-565876
  Duesternbrooker Weg 20                email: jhauser at ifm.uni-kiel.de
  24105 Kiel, Germany



More information about the Python-list mailing list