Mail-related libraries


(Austin Ziegler) #1

I have a pair of scripts that I need to write soon, and I would
prefer to do them in Ruby. Being new to the Ruby community, though,
I’m not quite sure which libraries will help me accomplish my task.

Both scripts will be responsible for downloading messages from a POP3
account. This is the first necessary library, and one that I’m not
quite seeing. I suspect that there’s a library in SGMail or something
I could pull out of there, but I was wondering if there was another
library. One of the scripts will be required to delete the messages
that it has downloaded upon completion. Both scripts will also be
examining the downloaded messages; I suspect that RubyFilter/RubyMail
will be best for this part of the task.

One script (call it “remailer”) will download messages and first
verify that they are from a small set of authorized email addresses.
All other messages will be ignored. It will look in the message for
an ‘X-Actually-To’ address. This can be a header or it can be the
first line of the message. The script will strip that information
from the message and then send the message otherwise unmodified to
the address in the ‘X-Actually-To’ field. This script is necessary
because I’m on a DSL connection which has a stupid mail
authentication policy (if you’re one of our IP addresses, you’re
okay) and doing dial-in for the user will be unnecessarily expensive
on vacation. Again, I think that RubyFilter can actually handle
resending the message – if RubyMail can handle safely modifying the
message. At the same time, a quick confirmation message will be sent
to the authorized user. This script will be deleting the messages
that it has processed from the POP server.

The second script (call it “forwarder”) will forward certain classes
of mail (specified by text filtering, really, but also to eliminate
spam) to my TreoMail account. This one may NOT delete messages that
it forwards.

I have no doubt that these can be done in Ruby; what I don’t know is
how easily/quickly, and what libraries exist to support this sort of
need.

-austin
– Austin Ziegler, austin@halostatue.ca on 2002.07.01 at 02.19.45


(Dave Thomas) #2

Austin Ziegler austin@halostatue.ca writes:

I have a pair of scripts that I need to write soon, and I would
prefer to do them in Ruby. Being new to the Ruby community, though,
I’m not quite sure which libraries will help me accomplish my task.

Both scripts will be responsible for downloading messages from a POP3
account. This is the first necessary library, and one that I’m not
quite seeing.

Comes with Ruby:

require “net/pop”

Sending mail is done with “net/smtp”

There are examples towards the bottom of

http://www.rubycentral.com/book/lib_network.html

Cheers

Dave