#! /usr/local/bin/perl #################################################### #BooAutoMailResponder,v1.11 / this program is free.# # (C) BooBooClub 2001-2010 # #################################################### #set data $success = './success.html'; $sendmail = '/path/to/sendmail'; $from = 'your@mail.address'; $subject = 'From BooAutoMailResponder'; $txt = './responce.txt'; $log = 'on'; $logfile = './logfile.txt'; #read lib require './jcode.pl'; require './bmail.pl'; #time $ENV{'TZ'}='JST-9'; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = ($year + 1900); $mon++; if ($sec < 10) { $sec = "0$sec";} if ($min < 10) { $min = "0$min";} if ($hour < 10){ $hour = "0$hour";} if ($mon < 10) { $mon = "0$mon";} if ($mday < 10){ $mday = "0$mday";} $time = "$year/$mon/$mday $hour:$min:$sec"; #read if ($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else{ $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } if ($FORM{'mail'} =~ /[^\w\-\.\@]/ || $FORM{'mail'} !~ /\@/ || $FORM{'mail'} !~ /\./ || $FORM{'mail'} =~ /^\@/ || $FORM{'mail'} =~ /\@$/ || $FORM{'mail'} =~ /\.$/){ &mailerror; } open (TXT,"$txt"); @txt = ; close (TXT); $txt = join ('',@txt); $txt =~ s/(\r\n|[\r\n])\.(\r\n|[\r\n])/$1\. $2/g; if($txt =~ /\r\n/){ $txt =~ s/\r\n/\n/g; } $to = $FORM{'mail'}; $to =~ s/\r\n|[\r\n]//g; $from =~ s/\r\n|[\r\n]//g; $subject =~ s/\r\n|[\r\n]//g; if($from eq '' || length($from) > 245 || $from =~ /\@.*[\,\@]/){ &submiterror; } &jcode'convert(*subject,'jis'); &jcode'convert(*txt,'jis'); $subjectm = &bmail::mime(header,$subject); open(SEND,"|$sendmail -t"); print SEND "From: $from\n"; print SEND "Subject: $subjectm\n"; print SEND 'MIME-Version: 1.0',"\n"; print SEND "To: $to\n"; print SEND 'X-Mailer: BooAutoMailResponder',"\n"; print SEND "X-Mailer-Produced-by: BooBooClub\n"; print SEND 'Content-Type: text/plain; charset=iso-2022-jp',"\n\n"; print SEND "$txt\n"; close (SEND); if($log eq 'on'){ $logdata = "$time\,$FORM{'mail'}\,$ENV{'REMOTE_ADDR'}\n"; open (LOG,">>$logfile"); print LOG $logdata; close (LOG); } open (HTML,"$success"); @html = ; close (HTML); $html = join('',@html); print "Content-type: text/html\n\n"; print $html; exit 0; sub mailerror{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print 'Error'."\n"; print ''."\n"; print '

Input Error

メールアドレスが間違えていないかご確認ください。

'."\n"; print 'BACK
'."\n"; print ''."\n"; exit 0; } sub submiterror{ print "Content-type:text/html\n\n"; print ''."\n"; print ''."\n"; print 'Error'."\n"; print ''."\n"; print '

Submit Error

送信エラーです。

'."\n"; print 'BACK
'."\n"; print ''."\n"; exit 0; }