CGI::Application::MailPage - module to allow users to send HTML pages to friends.
use CGI::Application::MailPage; my $mailpage = CGI::Application::MailPage->new( PARAMS => { document_root => '/home/httpd', smtp_server => 'smtp.foo.org' }); $mailpage->run();
CGI::Application::MailPage is a CGI::Application module that allows users to send HTML pages to their friends. This module provides the functionality behind a typical ``Mail This Page To A Friend'' link.
To use this module you need to create a simple ``stub'' script. It should look like:
#!/usr/bin/perl use CGI::Application::MailPage; my $mailpage = CGI::Application::MailPage->new( PARAMS => { document_root => '/home/httpd', smtp_server => 'smtp.foo.org', }, ); $mailpage->run();
You'll need to replace the ``/home/httpd'' with the real path to your document root - the place where the HTML files are kept for your site. You'll also need to change ``smtp.foo.org'' to your SMTP server.
Put this somewhere where CGIs can run and name it something like
mailpage.cgi
. Now, add a link in the pages you want people to be
able to send to their friends that looks like:
<A HREF="mailpage.cgi">mail this page to a friend</A>
This gets you the default behavior and look. To get something more to your specifications you can use the options described below.
CGI::Application modules accept options using the PARAMS arguement to
new()
. To give options for this module you change the new()
call in the ``stub'' shown above:
my $mailpage = CGI::Application::MailPage->new( PARAMS => { document_root => '/home/httpd', smtp_server => 'smtp.foo.org', use_page_param => 1, } );
The use_page_param
option tells MailPage not to use the REFERER
header to determine the page to mail. See below for more information
about use_page_param
and other options.
<A HREF="mailpage.cgi?page=http://host/page.html">mail page</A>
You'll have to replace http://host/page.html with the url for each page you put the link in. You could cook up some Javascript to do this for you, but if the browser has working Javascript then it probably has a working REFERER!
@INC
. Pass in the path to
your custom template as the value of this parameter.
See HTML::Template for more information about the template syntax.
@INC
. Pass in the path to your custom template as the value
of this parameter.
See the HTML::Template manpage for more information about the template syntax.
@INC
. Pass in the path to your custom template as the value of
this parameter.
See the HTML::Template manpage for more information about the template syntax.
#!/usr/bin/perl -w use CGI::Application::MailPage;
sub p_to_q { my $filename = shift; open(FILE, $filename) or die;
my $buffer; while(<FILE>) { s/p/q/g; $buffer .= $_; }
return $buffer; }
my $mailpage = CGI::Application::MailPage->new( PARAMS => { document_root => '/home/httpd', smtp_server => 'smtp.foo.org', read_file_callback => \&p_to_q, }, ); $mailpage->run();
Copyright 2002, Sam Tregar (sam@tregar.com)
Questions, bug reports and suggestions can be sent to the CGI::Application mailing list. You can subscribe by sending a blank message to cgiapp-subscribe@lists.vm.com. See you there!
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.