当我从 Perl CGI 脚本调用 mutt 时,为什么它会失败?

发布于 2024-08-11 05:24:30 字数 389 浏览 2 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

桃气十足 2024-08-18 05:24:30

请参阅我的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.

黄昏下泛黄的笔记 2024-08-18 05:24:30

您看到什么错误?

特别是 $! 中有什么?

可能是 CGI 进程无法执行 Mutt - 如何记录脚本的用户 ID 和当前路径:

print LOG getpwuid(
lt;) . "\n";
print LOG $ENV{PATH} . "\n";

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:

print LOG getpwuid(
lt;) . "\n";
print LOG $ENV{PATH} . "\n";

Is the location of Mutt's executable in the path, and does that user (probably 'apache') have permission to execute it?

喜你已久 2024-08-18 05:24:30

您可能还想考虑使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文