[plug] POP3, Perl, Flock, UID, message id [Slightly][OT]
Tim White
weirdo at tigris.org
Wed Jun 9 14:55:01 WST 2004
A nice mix of questions in a lovely mailing list.
I am looking at putting a pop3 server on a windows box(Due to it being
impossible to put linux on the box :( ). To do this I have downloaded a
perl script that someone wrote in 99 and am modifying it for the situation.
In my work I have discovered a nice little problem. The mailbox is not
locked between reading the messages and writing them out again.[1] (See
below for all those new to [1][2] ...)
Can anybody tell me how other clients handle mail being written to the
spool while a client is logged in. The problem is only if you delete some
messages and new messages have come in between you logging in and logging
off. The problem appears to be locking a closed file which I think I can
fix by keeping the file open but then what does the SMTP server (spool
writing app) do when it finds the file locked?
Another question. I have a perl fetchmail (modified pfetchmail i think(mod
allows it to write straight to a spool)) script that has an option to leave
messages on server. (BTW, the script is not in English so I am translating
it for anyone who wants it) I want it to be able to download new messages
only that aren't in the spool if this switch is on. To do that I am going
to read in from the spool all the message IDs and compare with those on the
server. I know that POP has UIDL that gives a MD5 or something and was
wondering what other clients did. Do they use the UIDL or Message ID? I
would think Message ID as the MD5 checksum could be any algorithm (RFC
doesn't specify that it has to be MD5, it suggests that MD5 is used but it
is upto the server)
Also I know that the POP3 server uses the "From " header (with a space not
colon) to differentiate between messages in the spool. This is how other
servers appear to run. Should I be sending that header as well. Otherwise
how do I get my fetchmail script to make a valid spool? Do other servers
send it?
I am asking these questions mainly because I don't want to install a real
pop3 server just for testing.
Thanks
Tim
[1] The basics of the perl server are:
1) Open spool
2) read messages into array
3) lock file (flock with exclusive locking)
4) CLOSE the spool
5) MAIN PROGRAM THAT INTERACTS WITH CLIENT AND SELECTS MESSAGES
FOR DELETEING
6) IF messages have been deleted then
1) Open spool for writing
2) write out messages that are not marked for deletion
3) unlock spool
4) close spool
ELSE
1) close
weirdo AT tigris DOT org (MSN Enabled) | ICQ# 255176389 | Riverton, Perth, WA
More information about the plug
mailing list