Michael Peters > CGI-Application-MailPage > CGI::Application::MailPage

Download:
CGI-Application-MailPage-1.7.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.7   Source  

NAME ^

CGI::Application::MailPage - module to allow users to send HTML pages to friends.

SYNOPSIS ^

   use CGI::Application::MailPage;
   my $mailpage = CGI::Application::MailPage->new(
                  PARAMS => { document_root => '/home/httpd', 
                              smtp_server => 'smtp.foo.org' });
   $mailpage->run();

DESCRIPTION ^

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.

OPTIONS ^

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.

INPUT VALIDATION ^

MailPage uses Data::FormValidator to validate the input the user fills in when presented with the email information form. By default the following validation rules are used:

name

Required. Can only contain word characters (\w), apostrophes ('), hyphens (-), and open or closed parenthesis, commas (,) and periods (.) with a maximum length of 50 characters

from_email

Required. Must be a valid email address.

to_emails

Required. A list of email addresses separated by whitespace or commas. All email addresses must be valid with at most max_emails_per_request individual addresses.

subject

Required. Can only contain word characters (\w), apostrophes ('), hyphens (-), and open or closed parenthesis, commas (,), periods (.), question marks (?) and exclamation points (!) with a maximum length of 50 characters

Required.

note

An optional text to send in the email. Can contain anything but a NULL byte with a maximum length of 250 characters.

format

Required. Must be one of the following values:

both_attachment
html
html_attachment
text
text_attachment
url
page

Can contain any characters except new lines (\n) or NULL bytes with a maximum length of 256 characters.

Each field is untainted, so it can be safely processed. You can customize these rules with the validation_profile parameter.

Error Messages

MailPage will pass flags for each error message into the template to be used as the template sees fit. The following error messages are created for each field:

missing_$field

If a required field is not present.

any_missing

If any required field is not present.

invalid_$field

If a field is present but fails validation.

any_invalid

If any field fails validation

error_$field_name

If a field is not present or fails the validation

any_errors

If any field is not present or fails the validation

AUTHOR ^

Copyright 2002, Sam Tregar (sam@tregar.com).

Co-maintainer Michael Peters (mpeters@plusthree.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!

LICENSE ^

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

CGI::Application, HTML::Template

syntax highlighting: