【发布时间】:2014-02-01 15:29:28
【问题描述】:
邮件程序错误:无法执行:/usr/sbin/sendmail
我用的是debian服务器,文件权限是777(all allowed),所以不能执行,这是为什么?
//Create a new PHPMailer instance
$mail = new PHPMailer();
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('admin@test.com', 'test');
//Set an alternative reply-to address
//$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress($_POST['email'], $_POST['name']);
//Set the subject line
$mail->Subject = 'PHPMailer sendmail test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML("from test");
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.gif');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
【问题讨论】:
-
Dis 不是权限问题,因为您没有收到权限被拒绝错误
-
任何 777 模式都是严重的安全问题。您应该恢复到系统的早期备份,或者从头开始重新安装。
-
@tripleee
sendmail默认为 777,放心吧!没有人从头开始重装系统,就因为你chmod一个文件?你是认真的吗? -
如果系统二进制文件是世界可写的,你不知道你是否已经烤好了。符号链接显示为 lrwxrwxrwx,但实际目标必须 不系统上的每个用户都可写。
-
@tripleee 无论您说什么,都与我的回答无关。事实是——它是可写的。我的建议是让它默认,不要让它成为我喜欢的错误方式。它是
777的原因是未知的(至少对我来说,755 绰绰有余)。我可以理解,如果它只是符号链接但它出现(通过查看包),例如sendmail-bin_8.14.4-2.1ubuntu4_amd64.deb二进制文件也被 chmod 为777。无论如何,感谢您指出!