FromName = "Rajasek-6ren">
gpt4 book ai didi

php - 无法实例化邮件功能。为什么会出现这个错误

转载 作者:IT王子 更新时间:2023-10-28 23:58:56 26 4
gpt4 key购买 nike

当我尝试通过 PHPMailer 发送邮件时,收到此错误消息。我的代码如下:

<?
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

您可能还需要如上所述为其配置适当的权限。

关于php - 无法实例化邮件功能。为什么会出现这个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1944631/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com