#!/usr/bin/perl -w
$PSSWD = 'foo'; # Type in your program access password here!
=pod
AUTHOR
Tommy Butler <cpan@atrixnet.com>
phone: (817)-468-7716
6711 Forest Park Dr
Arlington, TX
76001-8403
COPYRIGHT Tommy Butler, all rights reserved.
LISCENCE This library is free software, you may redistribute
and/or modify it under the same terms as Perl itself.
INSTALLATION (3 easy steps)
All non-standard modules used in this script may be found in the
ooOPps Open Source Code Library under its "modules" section. Note
that some modules use others. The ooOPps Code Library is at
<URL: http://ooopps.sourceforge.net/pub/ >
1. Place this script in your cgi bin directory.
2. Change permissions on this script to 755 on linux/unix systems
by using your FTP client software, or from a command line shell
by typing the following command after entering the directory where
this script is located:
chmod -v 755 [ script name ]
3. Create a subdirectory inside your cgi-bin directory named 'modules'
and place the modules used by this script into that directory. Create
subdirectories within it according to the modules used in this program.
Refer to the itemized list below for more specific information:
"Mailer::Simple"
used by: This program
file name: Simple.pm
directory: modules/Mailer/
get it at: /pub/modules/Mailer/Simple.pm
"Handy::Dandy"
used by: This program
file name Dandy.pm
directory: modules/Handy/
get it at: /pub/modules/Handy/Dandy.pm
"OOorNo"
used by: Handy::Dandy
file name: OOorNo.pm
directory: modules/
get it at: /pub/modules/OOorNo.pm
"Handy::Dandy::TimeTools"
used by: Handy::Dandy
file name: TimeTools.pm
directory: modules/Handy/Dandy
get it at: /pub/modules/Handy/Dandy/TimeTools.pm
=cut
++$|;
require 5.6.0;
use vars qw( $PSSWD ); use strict; use lib './modules';
use CGI qw( header param ); use Mailer::Simple; use Handy::Dandy 'html_escape';
my($cgi) = CGI->new(); my($mailman) = Mailer::Simple->new();
print(header, &email_form) and exit unless param('message');
print(header, error('Invalid Password.'))
and exit if (param('password') ne $PSSWD);
my($eml) =
{
# defaults to 'text/plain', but you can set it to 'text/html' if you
# want to send an email in formatted html by assigning a value of
# 'text/html' to this argument
'contype' => param('contype'),
# email address for the sender of this message
'from' => mail_field(param('from name'),param('from')),
# the email address at which you wish receive replies to this message
'reply to' => mail_field(param('reply to'),param('reply to name')),
# email address for the recipient of this message
'to' => mail_field(param('to name'),param('to')),
# you can specify an email address of someone to whom you wish to
# direct a 'carbon copy' of the email.
'cc' => mail_field(param('cc name'),param('cc')),
# you can specify an email address of someone to whom you wish to
# direct a 'blind carbon copy' of the email.
'bcc' => mail_field(param('bcc name'),param('bcc')),
# subject of the message
'subject' => param('subject'),
# message body
'message' => param('message'),
# the number of columns at which to wrap plain-text email.
# defaults to a value of '80'
'wrap at' => param('wrap at'),
};
$mailman->mail(%$eml);
map { $eml->{ $_ } = html_escape($eml->{ $_ }) } keys(%$eml);
print(header, mail_sent($eml));
# --------------------------------------------------------
# subroutine declarations
# --------------------------------------------------------
sub mail_field { $_[0] && $_[1] ? qq["${\$_[0]}" <${\$_[1]}>] : '' }
sub email_form { <<__HTML__ }
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en">
<head>
<title>Mailman</title>
<meta
http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<style
type="text/css"
xml:space="preserve">
<!-- FORM { display: inline; } -->
</style>
</head>
<body>
<div class="copy">
<div> </div>
<div>
<span class="big"><strong>the Mailman</strong></span>
<div> </div>
<div class="indent20">
<form method="POST">
<table
cellspacing="1"
cellpadding="2"
border="0">
<tr>
<td
width="125"
class="small">password  </td>
<td><input
type="text"
name="password"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">recipient's name  </td>
<td><input
type="text"
name="to name"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">recipient's email  </td>
<td><input
type="text"
name="to"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">sender's name  </td>
<td><input
type="text"
name="from name"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">sender's email  </td>
<td><input
type="text"
name="from"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">reply to name  </td>
<td><input
type="text"
name="reply to name"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">reply to email  </td>
<td><input
type="text"
name="reply to"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">CC name  </td>
<td><input
type="text"
name="cc name"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">CC email  </td>
<td><input
type="text"
name="cc"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">BCC name  </td>
<td><input
type="text"
name="bcc name"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">BCC email  </td>
<td><input
type="text"
name="bcc"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">subject  </td>
<td><input
type="text"
name="subject"
size="25" /></td>
</tr>
<tr>
<td
width="125"
class="small">content-type  </td>
<td>html   <input
type="radio"
name="contype"
value="text/html" /> plain-text   <input
type="radio"
name="contype"
value="text/plain"
checked="checked" /></td>
</tr>
</table>
<br
clear="all" />
<table
cellspacing="1"
cellpadding="2"
border="0">
<tr>
<td
colspan="2"
class="small">
message
<div> </div>
<textarea
name="message"
rows="15"
cols="80"></textarea></td>
</tr>
<tr>
<td
colspan="2"
class="small">
<br />
send message   <input
type="submit"
value="send email" /></td>
</tr>
</table>
</form>
</div>
</div>
<p> </p>
</div>
</body>
</html>
__HTML__
sub mail_sent { <<__SENT__ }
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en">
<head>
<title>Error</title>
<meta
http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
</head>
<body>
<div class="copy">
<div> </div>
<div>
<span class="big"><strong>the Mailman</strong></span>
<div> </div>
<div class="indent20">
<table
cellspacing="1"
cellpadding="2"
border="0">
<tr>
<td
width="125"
class="small">recipient  </td>
<td>${\($_[0]->{'to'}||'')}</td>
</tr>
<tr>
<td
width="125"
class="small">sender  </td>
<td>${\($_[0]->{'from'}||'')}</td>
</tr>
<tr>
<td
width="125"
class="small">reply-to  </td>
<td>${\($_[0]->{'reply to'}||'')}</td>
</tr>
<tr>
<td
width="125"
class="small">CC  </td>
<td>${\($_[0]->{'cc'}||'')}</td>
</tr>
<tr>
<td
width="125"
class="small">BCC  </td>
<td>${\($_[0]->{'bcc'}||'')}</td>
</tr>
<tr>
<td
width="125"
class="small">subject  </td>
<td>${\($_[0]->{'subject'}||'')}</td>
</tr>
<tr>
<td
width="125"
class="small">content-type  </td>
<td>${\($_[0]->{'contype'}||'')}</td>
</tr>
</table>
<br clear="all" />
<table
cellspacing="1"
cellpadding="2"
border="0">
<tr>
<td
colspan="2"
class="small">
message
<div> </div>
${\($_[0]->{'message'}||'')}
</td>
</tr>
</table>
</div>
</div>
<p> </p>
</div>
</body>
</html>
__SENT__
sub error { <<__ERR__ }
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en">
<head>
<title>Error</title>
<meta
http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
</head>
<body>
<p> </p>
<div class="indent10">
<div class="fpx22">
<strong class="alert">An error has occurred.</strong>
</div>
<div> </div>
<div class="indent15">
<div class="px700">
@_
</div>
</div>
</div>
<p> </p>
</body>
</html>
__ERR__