#!/usr/bin/perl # maildecG.pl: Mail decode # Copyright (c) 1996 GOMASUKE <kibita@orange.or.jp> # Orange Internet Service USER, Japan # require 'jcode.pl'; chop($day = `date`); %m = ("Jan","01","Feb","02","Mar","03","Apr","04", "May","05","Jun","06","Jul","07","Aug","08", "Sep","09","Oct","10","Nov","11","Dec","12"); ($w,$mm,$d,$t,$g,$y) = split(' ',$day); $d = substr("0$d", -2); $date = "$w, $m{$mm}/$d/$y $t $g"; $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "GET") { $dat = $ENV{'QUERY_STRING'}; } else { read(STDIN, $dat, $ENV{'CONTENT_LENGTH'}); } $ag = 0; @buf = split('&',$dat); foreach $item (@buf) { ($var,$value) = split('=',$item); $value =~ tr/+/ /; $value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg; $value =~ s/\x0d\x0a/\x0a/g; $value =~ s/\x0d/\x0a/g; &jcode'convert(*value,'jis'); $itm{$var} = $value; $arg[$ag] = $var; $ag++; } $mailto = "/usr/bin/sendmail -t"; $myadrs = $itm{'myadrs'}; $myadrs = "foo@hogehoge"; # 宛先を変更して他所からの利用を不能にする $url = $itm{'url'}; $name = $itm{'name'}; $email = $itm{'email'}; if ($email eq "") { print "Content-type: text/html\n\n"; print "<H1>Input your e-mail address</H1>\n"; exit; } $org = $itm{'org'}; if ($org eq "") { $org = "WWW net surfer"; } $subject = $itm{'subject'}; if ($subject eq "") { $subject = "no subject"; } $rr = $itm{'rr'}; $cc = $itm{'cc'}; $bcc = $itm{'bcc'}; open(ML,"| $mailto"); print ML <<EOF; From: $email Reply-To: $email Organization: $org X-Sender: Kibita\'s mail decode cgi script X-Mailer: maildecG\.pl Ver\.1\.00 To: $myadrs EOF if ($cc eq "1") { print ML "Cc: $email\n"; } if ($bcc eq "1") { print ML "Bcc: $email\n"; } if ($rr eq "1") { print ML "Return-Receipt-To: $email\n"; } print ML <<EOF; Subject: $subject Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit ******* SENDER INFORMATION ******* DATE : $date NAME : $name E-MAIL : $email REMOTE_HOST : $ENV{'REMOTE_HOST'} REMOTE_ADDR : $ENV{'REMOTE_ADDR'} HTTP_USER_AGENT : $ENV{'HTTP_USER_AGENT'} HTTP_REFERER : $ENV{'HTTP_REFERER'} ********************************** EOF # 先頭項目(9個)以降の追加項目の印刷 $ag=@arg; $ag--; foreach $cnt (9..$ag) { print ML "$arg[$cnt] = $itm{$arg[$cnt]}\n\n"; } close(ML); if ($url eq "") { print "Content-type: text/html\n\n"; print "<H1>E-mail send script completed</H1>\n"; } else { print "Location: $url\n\n"; } exit;フォームのサンプルはここに有りますので各自,内容を確認して勉強してみて下さい。
"url"の部分にURLを指定すればメッセージ送信後,任意のページを表示する事ができます。
注意
kibita@orange.or.jp