[Tutor] poplib questions

Ignacio Vazquez-Abrams ignacio@openservices.net
Thu, 20 Sep 2001 20:36:07 -0400 (EDT)


On Thu, 20 Sep 2001 fleet@teachout.org wrote:

> 1. I need the mail to go to my /var/spool/mail/fleet file. (Linux RH 7.1)
> Where should I open and close the file?  Open (for append) just before the
> "for i in range" statement and close after "a.quit()" as I have it below?
> Or should I open the file before the first getmail() call in the main
> program and close it after the last one?  Does it make any difference?

It doesn't matter as long as you expect to be the only program manipulating
it. See the answer to question 6 below.

> 2. Is there any reason for the three spaces before each line printed?

There shouldn't be.

> 3. Do I have the "import" in the correct place or should it be in within
> the function?

It's fine where it is.

> 4. Are there any serious security concerns with this script (other than
> the fact that the account names and passwords are in a text file)?

It accesses the mail file directly, so you could have a problem if more than
one program accesses it. See the answer to question 6 below.

> 5. I've inserted some linefeeds, else the messages become one huge long
> line in the "testbox"  file.  Is this going to mess up my procmail filter?

?

> 6. And, totally off topic, since there are no instructions activating
> procmail in my fetchmail script, I'm assuming that procmail "guards" the
> /var/spool/mail/fleet file and activates if anything shows up.  Am I
> close?

You're way, way off. When sendmail receives a message destined for a local
mailbox, it pipes it through procmail, and it's then procmail's job to open
the local mail file and dump the message into it.

> 7. Any suggestions to improve this would be greatly appreciated.

One thing that fetchmail as written by Eric S. Raymond does is that instead of
going through procmail, it dumps it to the local sendmail daemon. You might
want to look at using the smtplib module to do the same thing.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>