无法实例化邮件功能。为什么这个错误发生 [英] Could not instantiate mail function. Why this error occurring

查看:120
本文介绍了无法实例化邮件功能。为什么这个错误发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试通过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! \n\n 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆