############ FAKE EMAIL SEND LIB ############### # Copyright Info: This short library was written by: # Ellio Martina - ellio@elliomartina.com # Date: 14th of february 1999 # Being inspired to become involved with Perl through the # use of Selena Sol 's CGI-scripts. # Purpose: If you test run your cgi programs on a local server # you might not really want to send emails or want to test # while not being connected to the internet. # To avoid scripts from causing an error because no mail # can be send, the message is saved as a .txt file # You can check the contents of the file to see if it has been # send correctly. # I have created this for testing my web_store modifications # using Sambar41 Server on Win95 # You may use this freely, copy, distribute, change it or even # print it and eat the hardcopy for dinner if you like, # but be so kind to leave my name for credit ################################################# ### send fake email to tmp_dir ### ################################################# # Usage: Place this Library file in the Library directory # Add a require statement in your program. # (i.e. require 'mail_local_lib.pl) # or set the path_variable in the scripts' setup file to point to # this file instead of to: mail_lib.pl # Modify the next variable. Use full path on Win95 # The backslashes must be escaped on Win95 system # adding an extra backslash for everyone you are using. # (This might be the case also for other systems) # Location of fake email files created by this library $mail_txt_file_dir = "c:\\program files\\sambar41\\tmp"; sub send_mail { local($from, $to, $subject, $message) = @_; local($mail_txt_file); # If you use this Fake Mail routine with sending multiple emails # this script wil choke, so the fake email txt files are given a # unique id by generating a random filename for the "send" file. # This way you also can track back the contents of the created files # if you check your scripts repeatedly do { srand (time|$$); $mailtest_id = int(rand(1000)); $mailtest_id .= ".$$"; $mail_txt_file = $mail_txt_file_dir . "/" . ${mailtest_id} . "_email.txt"; } until !(-e $mail_txt_file); # Make sure does not already exists. # Saving the e-mail message to "xxxx_email.txt" file. open(MAIL, ">$mail_txt_file") || die $!; print MAIL "$message\n"; close(MAIL); } # End of send_mail subroutine 1; # End Librar