Skip to content

Instantly share code, notes, and snippets.

@rybesh
Created November 19, 2009 15:39
Show Gist options
  • Save rybesh/238824 to your computer and use it in GitHub Desktop.
Save rybesh/238824 to your computer and use it in GitHub Desktop.
download and mail a web page
#!/usr/bin/perl -w
use strict;
use WWW::Mechanize;
use MIME::Lite;
my $from = shift;
my $to = shift;
my $url = shift;
my $title = shift;
my $mech = WWW::Mechanize->new();
$mech->get($url);
my $html = $mech->content;
my $base = $mech->base;
$html =~ s|</head>|'<base href="'.$base.'"></head>'|eigs;
my $msg = MIME::Lite->new (
From => $from,
To => $to,
Subject => $title,
Type => 'multipart/mixed');
$msg->attach (
Type => 'text/html',
Data => qq{$html});
MIME::Lite->send('smtp', 'localhost', Timeout=>60);
$msg->send;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment