希望有人可以帮助那些没有CGI编码经验的用户。在昨天之前,当我们的客户提交订单时,以下代码工作正常。然后昨天他们的浏览器中会出现内部服务器错误消息。
当我们的托管公司遇到麻烦时,这就是他们的错误日志所说的:
20130508T200031:www.4printer.com/cgi-bin/mailit.cgi open | / usr / lib / sendmail -t -oi -oem:权限被拒绝 在/home/users/web/b643/ipw.i4printe/public_html/cgi-bin/mailit.cgi第110行
不幸的是,他们不支持编码问题。
代码的第110行只是说:
$msg->send();
这是整个CGI代码:
#!/usr/bin/perl
# webmaster@qnis.net
$date = `/bin/date`; chop($date);
# Read the Input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
if(!($buffer =~ /CUSTOMER/)){
print <<"(ERROR_MSG)";
Content-type:text/html
<center><font size='4'><b>No data was recorded. Please use your browsers back button and try again.
(ERROR_MSG) 出口; }
$mailprog = "/usr/sbin/sendmail";
$emailInfo = "";
open(MAIL, "|$mailprog -t") || do{ print "Can't open $mailprog!\n"; exit;};
print MAIL "To: ctsales2\@4printer.com\n";
# print MAIL "To: jim\@spiderbilt.com\n";
print MAIL "From: 4printWebForm\n";
print MAIL "Subject: California Financial Printing Order Form\n\n";
print MAIL "This form was submitted on $date\n\n";
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if ($value eq "SUBMIT INFORMATION") {
Next;
} else {
print MAIL "$name: $value\n\n";
$emailInfo = $emailInfo . "$name: $value<br /><br />";
}
} 关闭(MAIL);
$title='Perl Mail demo';
$from= 'info@4printer.COM';
$rcvd_cookies = $ENV{'HTTP_COOKIE'};
@cookies = split /;/, $rcvd_cookies;
foreach $cookie ( @cookies ){
($key, $val) = split(/=/, $cookie); # splits on the first =.
$key =~ s/^\s+//;
$val =~ s/^\s+//;
$key =~ s/\s+$//;
$val =~ s/\s+$//;
if( $key eq "4printerEmail" ){
use URI::Escape;
$user_id = uri_unescape($val);
}
}
## Mail Header
use MIME::Lite;
# SendTo email id
# create a new MIME Lite based email
my $msg = MIME::Lite->new
( Subject =&gt; “4Printer.com确认”, From =&gt; 'sales@4printer.com', To =&gt; $ USER_ID, Type =&gt; 'text / html的', 数据=&gt; “
<tr>
<td align="left">
<div width="300">
<font face="Arial" size="2">
<p>
'.$emailInfo.'
</p>
<p>
Your order has been received and is being processed. <br /><br />
Thank you for your order!
</p>
<br />
<font color="#5485a3"><b>California Financial Printing</b></font><br />
P.O. Box 25755<br />
Fresno, CA 93729-5755<br />
559.454.8414<br />
800.438.1449
</font>
</div>
</td>
</tr>
</table>
</td>
</tr>
” );
$msg->send();
print <<output;
Content-type:text/html
输出
非常感谢任何建议或意见。我提前谢谢你了!