Chinaunix

标题: 采用perl编写的邮件发送程序的奇怪问题? [打印本页]

作者: barrettyin    时间: 2004-02-18 14:26
标题: 采用perl编写的邮件发送程序的奇怪问题?
我写了一个邮件发送的测试程序(testMail.cgi),程序如下所示:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "hello world";
#$sMailPath = '/usr/bin/mail';
$sMailPath = '/usr/sbin/sendmail';
$sPemail = 'test@sohu.com';
open(MAIL, "|$sMailPath $sPemail" || die("Unable to open Mail Program.";
print MAIL "To: $sPemail\n";
print MAIL "From: jichitai\@www114.sakura.ne.jp\n";
print MAIL "Subject: test - Reply Notification\n";
print MAIL "Hello there!\n\n";
close(MAIL);

该段程序在命令行方式下运行,能发送邮件
但是如果在web状态下运行,却长时间没有响应,而且最终提示该页无法显示!
请问这是什么错误啊?为何会有这种差别呢?
同样的程序,在我自己的主机上是完全没有问题的,而到了外面租用的服务器上就不行了呢?
我们租用的服务器的操作系统是freebsd ,sendmail
作者: apile    时间: 2004-02-18 17:39
标题: 采用perl编写的邮件发送程序的奇怪问题?
url不對...
check httpd.conf設定..
與你的url一不一樣...
另外CGI..是不是設定有啟動...

besides..
print "content-type:text/html\n\n";
建議可以改成
print "content-type:text/plain\n\n";
輸出plain text...

最後面加上exit 0;
試試看...

另外也可能是sendmail的目錄不對..freebsd的位置..你得用
whereis 、which去查一下...
作者: barrettyin    时间: 2004-02-19 17:19
标题: 采用perl编写的邮件发送程序的奇怪问题?
谢谢apile,问题已解决
在程序最后加了 exit 0;就好了
真不知道怎么感谢你!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2