in reply to Email on every page hit

That depends on what you are using to generate the page. ASP, Embperl, CGI (pure perl), or what ? You just need to create a routine with the above code wrapped in and call it from the page you want to trigger this email.

You might also want to add a handler in Apache (You're using Apache aren't you ?) but that's OT isn't it ;) ?

Replies are listed 'Best First'.
Re: Re: Email on every page hit
by Anonymous Monk on Dec 05, 2003 at 19:35 UTC
    It will probably be an HTML page. Please advise further if possible. Thanks.

      for plain html files, you just need to install a PerlFixupHandler for the files you need to trigger.

      <Files ~ "\.html$"> PerlFixupHandler MyPackage::MailMe; </Files>

      Create a package somewhere in @INC that says.

      package MyPackage::MailMe; use Apache::RequestIO; use Apache::RequestRec; use Apache::Const -compile => 'OK'; use Mail::Sendmail; sub handler { my $r = shift; sendMail($r->uri); Apache::OK; } sub sendMail { my $page_visited = shift; my %mail = ( To => 'jones@company.com', From => 'smith@company.com', Subject => "Page visited", Message => "$page_visited was visited", ); $mail{smtp} = '111.22.333.444'; sendmail(%mail) || die "\nProblem! $Mail::Sendmail::error\n"; }

      This is untested and incomplete. Read the modperl docs to find out more.