精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● CGI>>实例分析>>CGI邮件附件发送源代码:Jeff Ledger\Ema

主题:CGI邮件附件发送源代码:Jeff Ledger\Ema
发信人: tanshuai()
整理人: workingnow(2002-10-30 13:51:57), 站内信件
#!/usr/bin/perl
#################################################################
# Email The File Version 1.0 #
# Copyright 1999 Jeff Ledger [email protected] #
# Created 7/9/99 Last Modified 7/9/99 #
#################################################################
# COPYRIGHT NOTICE: #
# Copyright 1999 Jeffrey D. Ledger All Rights Reserved #
# #
# Email The File 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 Jeffrey D Ledger from any liability that might #
# arise from it's use. #
# #
# Selling the code for this program without prior written #
# consent is expressly forbidden.  In other words, please ask #
# first before you try and make money off of my program. #
# #
# Obtain permission before redistributing this software over #
# the Internet or in any other medium.  In all cases copyright #
# and header must remain intact. #
#################################################################
# Set Variables
$mailprog = "/usr/bin/sendmail"; # Sendmail Location
$youremail = "tanshuai\@bigfoot.com"; # Your Email Address
$yourname = "Sam Tanshuai"; # Your Name
$aftersend = "http://www.cncenter.com/"; # Where to go after
$file = "efile.zip"; # File to send to user



# Set Your Options
$automessage  = "1"; # Send 'efile.letter' to user with file.
# 0 = NO / 1 = YES

$autoalert = "1"; # Email yourself alert when user gets a file.
# 0 = NO / 1 = YES

# Done #
#################################################################


#####################
# Get the form data #
#####################

read(STDIN, $values, $ENV{'CONTENT_LENGTH'});

# Split up the name-value pairs
@pairs = split(/&/, $values);

foreach $set (@pairs) {
   ($name, $itemvalue) = split(/=/, $set);

# Remove plus signs and any encoding present
   $itemvalue =~ tr/+/ /;
   $itemvalue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $itemvalue =~ s/<!--(.|\n)*-->//g;

   $FORM{$name} = $itemvalue; 
}                                     

##########################
# Set incoming Variables #
##########################

$email = $FORM{'email'};


##############################
# Send file to user in email #
##############################

open(MAIL, "|$mailprog -oi -t") or die;
 
# Create headers

print MAIL <<"END";
From: $yourname
To: $email
Subject: File: $file (uuencoded)

Requested File: $file

END
open(FILE, "uuencode $file $file|") or die;
while( <FILE>) { print MAIL; };

# Close the file and finish sending the mail

close(FILE);
close(MAIL);


##################################################################
# Send 'efile.letter' to requestor if automessage is toggled on. #
##################################################################

if ($automessage eq '1') {

# Send AutoResponse Email

open(MAIL, "|$mailprog -oi -t") or die;

# Create headers

print MAIL <<"END";
From: $yourname
To: $email
Subject: File Confirmation

END

open(FILE, "efile.letter") or die;
while( <FILE>) { print MAIL; }; 

close(FILE);
close(MAIL);       

}


######################################################################
##############
# (Peek-a-boo) Email alert to webmaster if someone gets a file if auto
alert is on. #
######################################################################
##############

if ($autoalert eq '1') {


open(MAIL, "|$mailprog -oi -t") or die;
 
# Create headers

print MAIL <<"END";
From: $yourname
To: $youremail
Subject: *EFILE REPORT*

EFILE ENGINE WAS USED BY: $email
END


# !!! you should check close exit codes

close(MAIL);

}


##############################################################
# Alert user that file is sent and send them somewhere else. #
##############################################################


print "Content-type: text/html\n\n";
print "<TITLE>File Sent!</TITLE>\n";
print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=$aftersend\">\n";
 
print "<CENTER>\n";
print "Your requested file has been sent to: $email <BR><Br>\n";
print "Teleporting.. or Click <a href=\"$aftersend\">here\n";





--
CGI版主(BM) ——  ☆★天水★☆ №↑1.
☆网络世界,你我共行,创出新意,创出未来,创出新世界!★
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
□E-Mail: [email protected] 【Http://ts.in-china.com】
〓I Seek You!ICQ NO. : 25856530 (AOL)
'''''''''''''''''''''''''''''''''''''''''''''''''''''

※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.96.86.60]

[关闭][返回]