无法实例化邮件功能.为什么会出现这个错误 [英] Could not instantiate mail function. Why this error occurring
本文介绍了无法实例化邮件功能.为什么会出现这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试通过 PHPMailer 发送邮件时,我收到此错误消息.我的代码如下:
When I'm trying to send mail through PHPMailer, i'm getting this error message. My code is below:
<?
require("phpmailer/class.phpmailer.php"); // First we require the PHPMailer libary in our script
$mail = new PHPMailer(); // Next we create a new object of the PHPMailer called $mail
$mail->From = "rajasekar.kcet@gmail.com";
$mail->FromName = "Rajasekar";
$mail->AddAddress("rajasekar.kcet@gmail.com"); // This is the adress to witch the email has to be send.
$mail->Subject = "First PHP Email message"; // This is the subject of the email message.
$mail->Body = "Hi!
This is my first e-mail sent through PHP."; // This is the actual email message
if(!$mail->Send()) // Now we send the email and check if it was send or not.
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent.';
}
?>
推荐答案
在 Ubuntu(至少 12.04)中似乎默认没有安装 sendmail.您必须使用以下命令安装它sudo apt-get install sendmail-bin
In Ubuntu (at least 12.04) it seems sendmail is not installed by default. You will have to install it using the command
sudo apt-get install sendmail-bin
您可能还需要如上所述为其配置适当的权限.
You may also need to configure the proper permissions for it as mentioned above.
这篇关于无法实例化邮件功能.为什么会出现这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文