当我从 Perl CGI 脚本调用 mutt 时,为什么它会失败?
我使用 Perl CGI 和 C++ 开发了一个数据库。我在将结果发送到邮件时遇到问题。我使用了以下代码:
print LOG "[",`date`,"] Sending mail to $email\n";
system (qq{mutt -s "MMM" -a $zip_file $email < $job_id});
if ( $? == 0) {
print LOG "[",`date`,"] Sending mail to $email :: SUCCESS ::\n";
}else {
print LOG "[",`date`,"] Sending mail to $email :: FAILED ::\n";
}
close LOG;
I have developed a database with the use of Perl CGI with C++. I have problem in sending the results to mail. I used the following code:
print LOG "[",`date`,"] Sending mail to $email\n";
system (qq{mutt -s "MMM" -a $zip_file $email < $job_id});
if ( $? == 0) {
print LOG "[",`date`,"] Sending mail to $email :: SUCCESS ::\n";
}else {
print LOG "[",`date`,"] Sending mail to $email :: FAILED ::\n";
}
close LOG;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅我的Perl CGI 脚本故障排除。如果这不能解决您的问题,它至少会帮助您提出问题,以便获得更多帮助。
您可能还喜欢brian 解决任何 Perl 问题的指南。
See my Troubleshooting Perl CGI scripts. If that doesn't solve your problem, it will at least help you develop your question so you can get more help.
You might also like brian's Guide to Solving Any Perl Problem.
您看到什么错误?
特别是
$!
中有什么?可能是 CGI 进程无法执行 Mutt - 如何记录脚本的用户 ID 和当前路径:
Mutt 可执行文件的位置是否在路径中,该用户(可能是“apache”)是否有权执行它?
What error do you see?
In particular, what is in
$!
?It could be that the CGI process cannot execute Mutt - how about logging the script's userid and current path:
Is the location of Mutt's executable in the path, and does that user (probably 'apache') have permission to execute it?
您可能还想考虑使用 Net::SMTP 模块,它将直接与邮件服务器通信,而不是依赖系统工具。这是一个更便携的解决方案,并且避免了整个权限问题。
You may also want to look at using the Net::SMTP module, which will communicate directly with the mail server instead of depending on system tools. This is a more portable solution, and avoids the whole permissions issue.