#!/usr/local/bin/perl -w #EDIT THE ABOVE LINE TO POINT TO PERL ON YOUR SYSTEM # #File: MailList_basic.pl - Version 3.00 # #Get the current working directory to add to the list of places to search #for the files specified by the "require" statements. $ENV{"PATH_TRANSLATED"} =~ s/\w+\..{1,}$//; push (@INC,$ENV{"PATH_TRANSLATED"}); # # This program was written to support basic mailing-list functionality #without being dependent on an actual email alias for the mailing list. This #increases the portability while also significantly reducing the possibilitiy #of spammers spamming members. # # This particular file will do one of the following depending on the #parameters passed to it: # 0 - Print subscribe form. This is done by default. # 1 - Mail confirmation subscribe email to the user requesting to sign up. # 2 - Subscribe to the list if the user clicks on the link within their confirmation email. # #REQUIREMENTS: # 1) Perl Version >= 5.003 OR ActiveState Active Perl Version >= 5.6.1 # 2) You must have a mail server running on the machine this script # is installed on. # 3) The CPAN MIME::Base64 Perl Module must be installed (comes with ActivePerl) # 4) The CPAN Net::SMTP Perl Module must be installed (comes with ActivePerl) # 5) The "lozcgi.pl" perl module. It's included as part of the archive and # available from http://www.davelozinski.com/scripts/ # #INSTALLATION: # 1) Set the path to the "require" statement below if you do not keep all your files # in the same directory. # 2) Set the values located in the "MailListConfigs_basic.pl" # file. ALL VALUES SHOULD BE ENCLOSED IN QUOTES. # 3) Complete the "installation" section of the file "MailListAdmin_basic.pl". # #RUNNING: # 1) The link to print the "Subscribe" form to your users is: # http://www.yourdomain.com/cgi-bin/MailList_basic.pl # #ADDITIONAL FEATURES AVAILABLE IN THE ADVANCED VERSION # 1) Providing the Unsubscribe form to allow users to automatically unsubscribe # from the list. # 2) Mail confirmation unsubscribe email to the user requesting to be removed. # 3) Unsubscribing the user from the list if they click on the link within their confirmation email. # 4) Support for multiple lists # #More details can be found at http://www.davelozinski.com/scripts/ # #WHERE/HOW TO PURCHASE THE ADVANCED VERSION # http://www.davelozinski.com/scripts # #LICENSE: # You are free to further develop/modify the source code to fit your #needs, but you MAY NOT resell and/or redistribute the source code in any #way, manner, fashion, or form without my hand-written consent! # # This license grants the purchaser of this archive the permission to #have an unlimited number of users use this script at any time. #Likewise, the purchaser may have any number of copies of this script as long #as the media that this program resides on or run from is owned by the purchaser. #If not, more licenses MUST be purchased. # #Examples: # 1) If you have your own webserver hosting your various customers, you only need once license #to run the code on your webserver to provide the email functionality to your clients hosted on your server. # 2) If you are designing websites for 3 individual clients, each of which wants the email functionality, #and each of which will be hosting their websites and emailer on their own server, #then you need to purchase 3 licenses. # #If you modify the source code in anyway for your own purposes, the #original header-comments must remain intact. # #REVISION HISTORY: # 3.00 07/31/04 Updated with advanced script. # 2.10 07/04/04 Updated to keep up with "advanced" version. # 2.00 04/12/03 Functionality improved. # 1.01 06/18/02 Corrected a Mail formatting issue # 1.00 03/01/02 Original Version # #CONTACT INFORMATION: # http://www.davelozinski.com/cgi-bin/email_lozinski.pl # use MIME::Base64; use Net::SMTP; use Fcntl ':flock'; # import LOCK_* constants require("lozcgi.pl"); require("MailListConfigs_basic.pl"); ################################ #NOTHING BELOW THIS LINE SHOULD NEED TO BE CONFIGURED ################################ &GetData; $a = defined($in{"a"}) ? $in{"a"} : 9; $e = defined($in{"e"}) ? $in{"e"} : ""; $AnError = 0; $ErrorMessage = ""; $Title = ""; $Title_String = ""; $Admin_Email = ""; $Email_Admin_With_List_Update = 0; $Mail_Subscribe_Thank_You_Letter = 0; $Send_HTML_Format = 0; $msg_body = ""; $subject = ""; $localtime = time + (60 * 60); $datestring = ""; $mailheaders = ""; $smtp = ""; if ($a =~ /\d/) { #0 - Print subscribe form if ($a>2 || $a<0) { #1 - Mail confirmation subscribe email $a = 0; #2 - Subscribe to list } } else { $a = 0; } $Title_String = "Mailing List "; if (($a==1 || $a==2) && ($e eq "")) { $AnError = 1; $ErrorMessage = "
Enter your email address below. A confirmation email will be sent to your email address.
__END_OF_HTML_CODE__ } } &FinishHTML(1); ################################ sub IsValidEmailAddress { my ($theAddress) = @_; $valid = $theAddress =~ /^(([\w\-\_])+(\.)*)+\@([\w\-\_]+\.)+[A-Za-z]{2,}$/i; } ### IsValidEmailAddress ################################ ################################ sub URLEncode { my ($theAddress) = @_; $theAddress =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg; return $theAddress; } ### IsValidEmailAddress ################################ ################################ #sub EmailAdmin # Sends an email to the address specified by $C_ADMIN_EMAIL #everytime someone confirms to subscribe or unsubscribe #from the mailing list. This function is only called if #$C_EMAIL_ADMIN_WITH_LIST_UPDATE is set to 1 (yes). ################################ sub EmailAdmin { my ($lt) = @_; $e = decode_base64($e); $mailheaders = "From: " . $Admin_Email . "\nReply-to: " . $Admin_Email . "\n"; $mailheaders .= "To: " . $Admin_Email . "\n"; $mailheaders .= "Subject: Mail List Update for: " . $Title . "\n"; $msg_body = "\"" . $e . "\""; $msg_body .= " subscribed to \"" . $Title . "\" on: "; $msg_body .= $lt . "\n"; if ($smtp = Net::SMTP->new("localhost")) { $smtp->mail("$Admin_Email"); $smtp->to("$Admin_Email"); $smtp->data(); $smtp->datasend("$mailheaders"); $smtp->datasend("\n"); $smtp->datasend("$msg_body\n"); $smtp->dataend(); $smtp->quit(); } else { print ("