exo : code : foo2mail

Foo2Mail is a perl module for taking the pain out of writing scripts that harvest content and mail it out. All you need to do is write a function to fetch the content and tell Foo2Mail what to fetch and where you want to send it and it does the rest. This includes checking the content's not already been sent, formatting the mail, sending it and doing some general cleanup.

As you need to provide the fetch function you'll need to have some perl knowledge to be able to use this. In use it looks a little like this:

        use Foo2Mail;

        # use LWP::Simple::get to fetch from url
        # use quick year/month/day date as id

        sub fetch {
            my ($self, $name, $target) = @_;
            my $content;
            if ($content = get($target)) {
                return {
                    name => $name,
                    content => $content,
                    id  =>  (localtime())[5,4,3],
            } else {
                $self->error('Failed to fetch $name ($target)');
                return undef;

        my %to_fetch = (
            a_site  =>  'http://example.com/example.html',
            b_site  =>  'http://example.com/example2.html',

        my $f2m = Foo2Mail->new(
            fetch       =>  \&fetch,
            to_fetch    =>  \%to_fetch,
            to          =>  'user@example.com',
            from        =>  'f2m@example.com',
            subject     =>  'Foo2Mail output',
        ) or die $Foo2Mail::ERROR


The following perl modules are required:




Foo2Mail is alpha software and has only been tested on Linux so may break on other platforms, especially non-unix based ones. Patches welcome though.

all the usual copyright stuff... [ copyright struan donald 2002 - present ], plus license