Piston

It’s time for my first code feed. After a bit of googling, I’ve decided to call my little email fetcher "piston". I skipped the whole "j" namespace as it’s worn a little thin for me – sorry Matt. The idea behind the name is that the app is like a piston, drawing email from the POP port, and pushing it to the SMTP port. I hope it doesn’t explode too many in between.

You can download it and try it out or just check out the source. The licence is the same as the current Apache licence with the names changed to protect the innocent.

It’s a little rough at the moment – not much in the way of configuration options, logging to the console, etc. It does the job for me and I will probably clean it a little later. To run the piston, you must create a directory ".piston" in your home directory and create a config file "config.xml" Here’s mine

<config loop="120">
  <smtp/>
  <pop username="user"
       password="password"
       host="pop1"
       smtpname="conor"
       max="100"
       nullMessageId="delete"
       duplicateMessageId="delete"/>
  <pop username="user"
       password="password"
       host="pop2"
       smtpname="conor"
       max="100"
       nullMessageId="delete"
       duplicateMessageId="delete"/>
</config>   

When I used to use Outlook, occasionally it would redownload a whole load of old mail sitting on the server. I think this occurs when there is a server problem and the UID values are rebuilt. When it happens it is a real pain. I set out to avoid that happening by tracking the messageIds of the messages currently on the server and not downloading these if I had already seen them. I discovered that a lot of viruses and spam does not have messageIds so I have an option to delete such messages. I have only seen one "legitimate" email that does not have a messageId (a super-12 footy tipping email). The nice thing is that virus payloads are often quite large and this approach allows me to delete them without downloading them. The tracking of messageIds also allows me to eliminate duplicates arising from cross-posting.

So if you send me an email without a messageId, I won’t read it – sorry.

DISCLAIMER This code is capable of deleting emails from your POP account. You need to satisfy yourself that it is working as you expect.

One Reply to “Piston”

Comments are closed.