home *** CD-ROM | disk | FTP | other *** search
- <%@ LANGUAGE="JScript" %>
-
- <%
-
- /*
- * ASP FormMail (BETA) for IIS 2.0+
- *
- * Version: v1.1b
- * Author : Larry [Josh] Ham (lham@geocel.com)
- * Geocel International (c) 1999
- *
- * Last Modified: 06/16/99
- * All rights reserved.
- * -----------------------------
- *
- * ASP FormMail is designed to mimic Matt Wright's popular perl FormMail script located
- * at http://www.worldwidemart.com/scripts/ The most important difference is that
- * ASP FormMail is designed mainly for IIS and does not require any third party programs
- * such as Perl or SendMail. It is completely handled internally via your web server.
- *
- * ASP FormMail has been designed around the server-side mail component "DevMailer".
- * However, it may be modified to use other compenents. View the README file for
- * for more information regarding "DevMailer".
- *
- * Please send bug reports, comments, etc to lham@geocel.com
- *
- * ASP FormMail may be used and modified free of charge by anyone so long as this
- * copyright notice and the comments above remain intact. By using this code
- * you agree to indemnify Lawrence [Josh] Ham from any liability that might arise
- * from its use.
- *
- * Selling the code for this program without prior written consent is
- * expressly forbidden.
- *
- * This is a beta release meant for testing only until this line is removed by the author.
- *
- * ChangeLog:
- * 1.0b - Inital Release
- * 1.1b - Add: a FILES hidden input tag to allow for easy addition
- * of user select file attachments.
- * Add: Included a copy of DVMAILER.DLL (the mailer object)
- * Fix: Notification when EMAIL tag is missing. (this was
- * required)
- */
-
- Response.Expires = 0;
-
- ConfigOptions = new Array(
- 'RECIPIENT',
- 'SUBJECT',
- 'REALNAME',
- 'REDIRECT',
- 'BGCOLOR',
- 'BACKGROUND',
- 'LINK_COLOR',
- 'VLINK_COLOR',
- 'TEXT_COLOR',
- 'ALINK_COLOR',
- 'SORT',
- 'PRINT_CONFIG',
- 'REQUIRED',
- 'ENV_REPORT',
- 'RETURN_LINK_TITLE',
- 'RETURN_LINK_URL',
- 'PRINT_BLACK_FIELDS',
- 'MISSING_FIELDS_REDIRECT'
- );
-
-
- /*
- * Add your mail server here. If your mail server does not allow message relaying (most do not)
- * then your recipient (set in your HTML form) account must exist on this server.
- */
-
- MailServer = "mailhost.geocel.com";
-
- /*
- * The default mail server port. Doubtful it needs to be changed.
- */
-
- SMTPPort = 25;
-
- /*
- * If you do not wish to check referers simply uncomment (put //) in front of the next * line.
- */
-
- checkReferers = true;
-
- /*
- * Referers allows forms to be located only on servers which are defined
- * in this field. This security fix from the last version which allowed
- * anyone on any server to use your FormMail script on their web site.
- */
-
- Referers = new Array('208.24.33.19', 'www.geocel.com');
-
- /*
- * Done with Configuration variables.
- */
-
-
- CheckRequired();
- CheckRecipient();
- CheckEMail();
- CheckReferers();
-
- SendMail();
-
- %>
-
- <%
- function SendMail() {
- DM = Server.CreateObject('Geocel.Mailer');
-
- /*
- * If the above line fails, run the following from the
- * the command line 'C:\>' - REGSVR32.EXE DVMAILER.DLL
- */
-
- body = "";
- if( Request('Subject').Count )
- sub = String(Request('Subject'));
- else
- sub = "ASP FormMail Results";
- if( Request('RealName').Count )
- from_name = String(Request('RealName'));
- else
- from_name = 'DevMailer';
-
- if( Request('EMail').Count )
- from_email = String(Request('EMail'));
- else
- from_email = "WWW Web Submission";
-
- DM.AddServer(MailServer, SMTPPort);
- DM.ContentType = "text/html";
- DM.Priority = 1;
- DM.Subject = sub;
- DM.FromName = from_name;
- DM.FromAddress = from_email;
- DM.AddRecipient(Request('Recipient'), '');
-
- /* Add any CC Recipients here and un-comment lines */
-
- // DM.AddCCRecipient("lham@geocel.com","Larry [Josh] Ham");
- // DM.AddCCRecipient("josh@geocel.com","Josh");
-
- /* Add any CC CRecipients here and un-comment lines */
-
- // DM.AddBCCRecipient("lham@geocel.com","Larry [Josh] Ham");
- // DM.AddBCCRecipient("josh@geocel.com","Josh");
-
- attach = Request('FILES').Count;
- if( attach ) {
- // look for multiple attachments (comma-seperated) - split them apart
- // into an array.
- mfiles = String(Request('FILES')).split(',');
- a = mfiles.length;
-
- filePath = 'C:\\ATTACH\\';
-
- /* Change this to a directory where your file attachments
- * are stored.
- */
-
- while( a-- ) {
- DM.AddAttachment( filePath + mfiles[a] );
- }
- }
-
- sort = Request('SORT').Count ? Request('SORT') : "";
- elements = null;
- esize = 0;
- if( sort == "alphabetic" || !sort.length ) {
- elements = new Array(Request.Form.count);
- en = new Enumerator(Request.Form);
- en.moveFirst();
- esize = 0;
- while( !en.atEnd() ) {
- elements[ esize ] = String( en.item() ).toUpperCase();
- esize ++;
- en.moveNext();
- }
- }
- else {
- elements = String(Request('SORT')).split(',');
- esize = elements.length;
- }
- if( sort == "alphabetic" ) {
- elements.sort();
- elements.reverse();
- }
- while( esize-- ) {
- if( !isOption( elements[ esize ] ) ) {
- form = Request( elements[esize] );
- blank = !form.Count || String(form).length < 1;
- if( blank ) {
- if( !Request('print_blank_fields').Count ) continue;
- }
- body += ('<b>' + elements[ esize ] + '</b> : ' + Request(elements[esize]) + '<br>\r\n');
- }
- }
- DM.Body = body;
- DM.Send();
-
- if( Request('REDIRECT').Count ) {
- Response.Redirect(Request('REDIRECT'));
- }
-
- PrintHeader(Request('TITLE').Count ? Request('TITLE') : 'Thank You');
- htitle = Request('TITLE').Count ? Request('TITLE') : 'Thank You for filling out this form.';
- d = new Date();
- %>
-
- <TABLE border=0 width="75%" bgcolor=#CCCCCC align="center">
- <TR>
- <TH>
- <FONT size=+2><%=htitle%></FONT>
- </TH>
- </TR>
- </TABLE>
- <TABLE border=0 width="75%" bgcolor=#99cccc align="center">
- <TR>
- <TD align="left" width="5%">
- O
- </TD>
- <TD>
- Below is what you submitted to <B><%=Request('RECIPIENT')%></B> on
- <%=d.toLocaleString()%>
- </TD>
- </TR>
- <%
- esize = elements.length;
- ecnt = 0;
- while( esize-- ) {
- if( isOption(elements[esize]) ) continue;
- form = Request( elements[esize] );
- blank = !form.Count || String(form).length < 1;
- if( blank ) {
- if( !Request('print_blank_fields').Count ) continue;
- }
- ecnt ++;
- ecnt % 2 ? bgcol = "#FFFFFF" : bgcol="#99cccc"; %>
- <TR>
- <TD bgcolor=<%=bgcol%> width="5%">
- O
- </TD>
- <TD bgcolor=<%=bgcol%>>
- <B><%=elements[ esize ]%></B>: <%=Request(elements[esize])%>
- </TD>
- </TR>
- <%
- }
- %>
- </TABLE>
- <BR>
- <CENTER>
- <P><HR size=1 width=75%>
- </CENTER>
- <BR>
- <% if (Request('RETURN_LINK_URL').Count && Request('RETURN_LINK_TITLE') ) { %>
- <CENTER>
- <UL>
- <LI>
- <A href="<%=Request('RETURN_LINK_URL')%>"><%=Request('RETURN_LINK_TITLE')%></A>
- </UL>
- </CENTER>
- <%
- }
- PrintFooter();
- }
-
- %>
-
- <%
- function isOption(option) {
- oc = ConfigOptions.length;
- option = option.toUpperCase();
- while( oc-- )
- if( ConfigOptions[oc] == option ) return true;
- return false;
- }
- %>
-
-
- <%
- function PrintHeader(title) { %>
- <HTML>
- <HEAD>
- <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
- <TITLE><%=title%></TITLE>
- </HEAD>
- <BODY
- <%
- if( Request('BGCOLOR').Count ) { %> BGCOLOR="<%=Request('BGCOLOR')%>" <% }
- else { %> BGCOLOR="#EEEEEE" <% }
- if( Request('BACKGROUND').Count ) { %> BACKGROUND="<%=Request('BACKGROUND')%>" <% }
- if( Request('LINK_COLOR').Count ) { %> LINK="<%=Request('LINK_COLOR')%>" <% }
- if( Request('VLINK_COLOR').Count ) { %> VLINK="<%=Request('VLINK_COLOR')%>" <% }
- if( Request('ALINK_COLOR').Count ) { %> ALINK="<%=Request('ALINK_COLOR')%>" <% }
- if( Request('TEXT_COLOR').Count ) { %> TEXT="<%=Request('TEXT_COLOR')%>" <% }
- %>
- >
- <%
- }
- %>
-
-
- <%
- function PrintFooter() {
- %>
- <BR>
- <TABLE align="CENTER" border=1 width="75%" bgcolor=#669999>
- <TR>
- <TD align="center">
- <FONT size=-1>
- <P>
- ASP FormMail v1.1b © 1999 GeoCel International<br>
- GeoCel International<br>
- <A href="http://www.geocel.com">http://www.geocel.com</a><br>
- </FONT>
- </TD>
- </TR>
- </TABLE>
- </BODY>
- </HTML>
- <%
- }
- %>
-
- <%
- function PrintError(error_title, error_message) {
- PrintHeader(error_title);
- %>
- <CENTER>
- <TABLE border=0 width="75%" bgcolor=#9C9C9C>
- <TR>
- <TH>
- <FONT size=+2><%=error_title%></FONT>
- </TH>
- </TR>
- </TABLE>
- <TABLE border=0 width="75%" bgcolor=#CFCFCF>
- <TR>
- <TD>
- <%=error_message%>
- </TD>
- </TR>
- </TABLE>
- <%
- PrintFooter();
- Response.End();
- }
- %>
-
-
- <%
- function CheckRequired() {
- if( !Request('REQUIRED').Count ) return;
- req = String(Request('REQUIRED')).split(',');
- bad = "";
- for( rx = 0; rx < req.length; rx ++ ) {
- if( !Request( req[rx] ).Count || String( Request(req[rx]) ).length < 1 ) {
- if( bad.length ) bad += ",";
- bad += String( req[rx] );
- }
- }
- if( bad.length ) {
- RequiredError( bad );
- }
- }
-
- function CheckReferers() {
- ref = String(Request('HTTP_REFERER')).toLowerCase();
- if( !ref.length ) return;
- else if( !checkReferers ) return;
- refs = ref.split('/');
- for( refc = 0; refc < refs.length; refc ++ ) {
- rcnt = Referers.length;
- while( rcnt-- ) {
- rtmp = String( Referers[rcnt] ).toLowerCase();
- if( rtmp == refs[refc] ) return;
- }
- }
- PrintError('Bad Referrer - Access Denied',
- 'The form attempting to use ASP FormMail resides ' +
- 'at <tt>' + Request.ServerVariables('HTTP_REFERER') + '</tt>, which is ' +
- 'not allowed to access this ASP page.<p>' +
- 'If you are attempting to configure ASP FormMail to run ' +
- 'with this form, you need to add the following to Referers, ' +
- 'explained in detail in the README file.<p>' +
- 'Add <tt>' + Request.ServerVariables('HTTP_HOST') + '</tt> to your <tt>' +
- '<b>\Referers</b></tt> array.');
- }
-
- function CheckRecipient() {
- if( Request('RECIPIENT').Count ) return;
- else {
- PrintError('ERROR: Missing EMail Recipient',
- 'No Recipient was specified in the data sent to ASP FormMail. Please ' +
- 'make sure you have filled in the "RECIPIENT" form field with an e-mail ' +
- 'address. More information on filling in recipient form fields can be ' +
- 'found in the README file.');
- }
- }
-
- function CheckEMail() {
- if( !Request('EMAIL').Count ) return;
- part1 = String(Request('EMAIL')).split('@');
- if( part1.length > 1 ) {
- part2 = String( part1[1] ).split('.');
- if( part2.length > 1 ) return;
- }
- PrintError('ERROR: Invalid EMail Address',
- '<br>The email address "' + Request('EMAIL') + '" is invalid. Please ' +
- 'use your browsers back button to return to the form and try again.<br>');
- }
-
- function RequiredError( missing_fields ) {
- mfr = Request('MISSING_FIELDS_REDIRECT').Count;
- re_text = "";
- if( mfr ) {
- mfr_location = Request('MISSING_FIELDS_REDIRECT');
- Response.Redirect( mfr_location );
- }
- else {
- re_text = "";
- mxa = missing_fields.split(',');
- for( mxc = 0; mxc < mxa.length; mxc ++ ) {
- re_text += '<LI> ' + mxa[ mxc ];
- }
- }
- PrintError('ERROR: Missing Fields',
- 'The following fields were left blank in your submission form:<p> ' +
- '<ul>' + re_text + '</ul><br>' +
- 'These fields must be filled in before you can successfully submit the form.<p>' +
- 'Please use your browser\'s back button to return to the form and try again.' +
- '<hr size=1>');
- }
- %>
-