(no subject)
Sunday, 19 January 2003 14:08Sometimes it bothers me when I'm at work and I want to see whether someone has written to my home address; most commonly this is when some website where I registered using my home address wants to send me something such as a password reminder and I can't access it until I get home, or when I want to sign up with a web site and they require confirmation.
So yesterday I had a go and wrote a little POP3 client using Net::POP3 and Mail::Internet (for message header parsing, to display From and Subject headers).
I'm sure that wheel's been invented hundreds of times before, but I didn't want it to do a lot; displaying an overview, reading messages, and deleting was enough.
(Maybe I could have used Mail::Box and friends since that suite of modules seems to do message parsing and POP3 as well, besides a host of other things. But it looked too complicated for a quick hack.)
Displaying the overview was the easiest since I just have to LIST to get a list of message IDs and message sizes in bytes. Then I can call TOP 2 on each message to get the headers and a tiny bit of the body and extract From and Subject from that.
Reading is a little more complicated. Messages are retrieved by message ID, but those IDs usually start counting at 1 and can be renumbered between sessions. But since HTTP is stateless, the script always closes the connection when it's finished. The next time it's called, the numbers might have changed. But as far as I understand it, UIDL is supposed to fix that -- call it on a message ID and the POP3 server gives you back a unique ID. So I made each subject a link back to the script but with parameters "action=read;which=<the UIDL>".
Then, since I read all the messages in at the start of the program, I just read the UIDLs as well. This gives me a hash reference ID => UIDL which I can invert to get a reverse lookup UIDL => MID. So then I look into this index to see whether a message with that UIDL exists. If so, I call GET on that message and just dump it straight to the screen (after putting <pre> around it and escaping & < > ").
Deleting was a little harder since, as I said, messages can be renumbered so I can't just pass in message IDs. But since I already had the code for finding a message based in UIDL, I just made it so that the check box said which message it was (MID) and also passed a hidden field for each message with the UIDL. (Looking back, it would have made more sense for the checkbox simply to have a value of the UIDL, but the way I have it now also works.)
Then when the script is called again, I see whether those messages exist, look up the MIDs and delete those messages. That way, I can delete those 80K spams I sometimes get from work and don't have to pull them over my ISDN connection.
So, not particularly elegant but it works. And since it's in a password-protected directory of my webserver, it should be moderately safe.
So yesterday I had a go and wrote a little POP3 client using Net::POP3 and Mail::Internet (for message header parsing, to display From and Subject headers).
I'm sure that wheel's been invented hundreds of times before, but I didn't want it to do a lot; displaying an overview, reading messages, and deleting was enough.
(Maybe I could have used Mail::Box and friends since that suite of modules seems to do message parsing and POP3 as well, besides a host of other things. But it looked too complicated for a quick hack.)
Displaying the overview was the easiest since I just have to LIST to get a list of message IDs and message sizes in bytes. Then I can call TOP 2 on each message to get the headers and a tiny bit of the body and extract From and Subject from that.
Reading is a little more complicated. Messages are retrieved by message ID, but those IDs usually start counting at 1 and can be renumbered between sessions. But since HTTP is stateless, the script always closes the connection when it's finished. The next time it's called, the numbers might have changed. But as far as I understand it, UIDL is supposed to fix that -- call it on a message ID and the POP3 server gives you back a unique ID. So I made each subject a link back to the script but with parameters "action=read;which=<the UIDL>".
Then, since I read all the messages in at the start of the program, I just read the UIDLs as well. This gives me a hash reference ID => UIDL which I can invert to get a reverse lookup UIDL => MID. So then I look into this index to see whether a message with that UIDL exists. If so, I call GET on that message and just dump it straight to the screen (after putting <pre> around it and escaping & < > ").
Deleting was a little harder since, as I said, messages can be renumbered so I can't just pass in message IDs. But since I already had the code for finding a message based in UIDL, I just made it so that the check box said which message it was (MID) and also passed a hidden field for each message with the UIDL. (Looking back, it would have made more sense for the checkbox simply to have a value of the UIDL, but the way I have it now also works.)
Then when the script is called again, I see whether those messages exist, look up the MIDs and delete those messages. That way, I can delete those 80K spams I sometimes get from work and don't have to pull them over my ISDN connection.
So, not particularly elegant but it works. And since it's in a password-protected directory of my webserver, it should be moderately safe.
GMX
Date: Sunday, 19 January 2003 11:43 (UTC)My ex-provider no longer provides dial-up services and said that "in the medium term" the mailboxes would go away as well, so I need a new POP3 location anyway. I was thinking about GMX (possibly the "Pro" service) but I'm not sure.
One problem is that IIRC they delete messages after 30 days (probably not in the pay service) but the main fault is that I need an SMTP service as well and AIUI GMX only allows you to send email with a GMX From address through their SMTP servers. (My old provider first authenticated through the dialup, which was fine when I called through them, and then later with POP-before-SMTP which works regardless of how I connect to the Internet.)
Do you have any good suggestions for this? That is, a place which provides POP3 boxes that preferably have no unduly small time or size limit? (This is useful for when my box dies and I can't get around to fixing it for several weeks, or I go on holiday, and the email piles up for a limited amount of time.) Also, that allows arbitrary "From" addresses through their SMTP relay, such as by authenticating with POP-before-SMTP? (Preferably a place that's netwise close to Germany.) I think those are my main requirements.
Re: GMX
Date: Sunday, 19 January 2003 12:32 (UTC)I'm more or less happy with GMX for the time being. Occasionally, people (Yahoo! Mail users) tell me their mails to me were rejected; I'll have to contact GMX support about this. Other than that, I'm currently not having any problems with GMX.
Re: GMX
Date: Monday, 20 January 2003 02:13 (UTC)But at least I found out that it is possible to send mail via GMX's mail servers and not use a GMX From address -- apparently, the mail server only checks the envelope sender but not the sender in the headers. So maybe I can start using GMX as a provider-independent mail service.
I've also heard good things about Arcor, which provide a free service which also lets you send email even if you're connected to the Internet through a different provider.
And I've heard good things about fastmail.fm (http://www.fastmail.fm/), though the free service includes no email sending and the one-time-fee "member" service includes no POP3 access -- only IMAP, but I use Pegasus Mail at home which requires a connection to the server while browsing IMAP folders (i.e. no local synchronisation, as far as I can see). And I'm not sure whether I want to pay $19.95 a year for email there. But other than that, it looks a little interesting, also the fact that they provide SpamAssassin for "full" accounts.
So, I shall have to see.