[Chicago-talk] emailing from perl

Joshua McAdams joshua.mcadams at gmail.com
Wed Aug 1 21:38:56 PDT 2007


It looks like there does need to be something local to your machine
handling the requests...
http://search.cpan.org/~gaas/libwww-perl-5.807/lib/LWP.pm#Mailto_Request

On 8/1/07, Jay Strauss <me at heyjay.com> wrote:
> Hi,
>
> I'm trying to use this program called "websec".  Its sort of a poor
> man's RSS.  Its supposed to look at a webpage and notice if its
> changed, and if so, email the updated page.
>
> I can't get the emailing to work on my machine.  I snipped out the
> code in the program that does the emailing (below).  I don't get how
> the email would be sent.  Doesn't there need to be some sort of email
> client setup to send this to an SMTP server or something?
>
> # Mail HTML document.
> # Params: filename, subject, recipient
> # Returns: none
> sub MailDocument() {
>     my $filename   = shift (@_);
>     my $subject    = shift (@_);
>     my @recipients = split /,/, shift (@_);
>     my $from       = shift (@_);
>     my $tmpstr     = $/;
>
>     undef $/;
>     open( FILE, "$filename" ) or die "Cannot open $filename: $!\n";
>     my $content = <FILE>;
>     close(FILE);
>
>     foreach $email (@recipients) {
>         $req = HTTP::Request->new( POST => "mailto:" . $email );
>         if ( $from ne "" ) {
>             $req->header( "From",   $from );
>             $req->header( "Sender", $from );
>         }
>         $req->header( "Subject",                   $subject );
>         $req->header( "Content-type",              "text/html" );
>         $req->header( "Content-Transfer-Encoding", "7bit" );
>         $req->header( "MIME-Version",              "1.0" );
>         $req->content($content);
>
>         $ua = new LWP::UserAgent;
>         my $resp = $ua->request($req);
>         die "Error mailing document: ".$resp->message()."\n" if $resp->is_error;
>     }
>
>     $/ = $tmpstr;
> }
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>


More information about the Chicago-talk mailing list