我曾嘗試下面的腳本通過PHPMailer的梅勒錯誤:無法實例化郵件功能
<?php
$sendfrm_name = 'Balakumar B';
$sendfrm_id = '[email protected]';
$sendtoname = 'myself';
$sendto = '[email protected]';
//$cc = '';
include("mail/PHPMailerAutoload.php");
include("mail/class.PHPMailer.php");
include("mail/class.smtp.php");
$mail = new PHPMailer;
//$mail-> isSMTP();
$mail-> Host = 'mail.mydomain.com'; //smtp.gmail.com
$mail->SMTPDebug = 2;
$mail-> SMTPAuth = true;
$mail->smtpConnect = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail-> Username = '[email protected]';
$mail-> Password = 'balakumar1`2345';
$mail-> SMTPSecure = 'tls';
$mail-> Port = 465; //587
$mail-> setFrom($sendfrm_id, $sendfrm_name);
$mail-> addAddress($sendto, $sendtoname);
$mail-> addReplyTo($sendto, $sendtoname);
//$mail->addCC($cc);
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = "Test Mail";
$mail->Body = "Name: ".$sendfrm_name ."<br /> Email: ".$sendfrm_id;
if(!$mail->send())
{
echo "Mailer Error: ".$mail->ErrorInfo;
}
else
{
echo ("<p>Message successfully sent!</p>");
echo "E-mail: ", $sendto, "<br />";
echo "Name: ", $sendtoname, "<br />";
echo "Subject: Test Mail<br />";
echo "Body: Body Of the Mail<br />";
}
?>
發送郵件,但我得到的郵件錯誤:
Could not instantiate mail function.
如何解決這個問題?上面我已經提到我的郵件服務器(mail.mydomain.com)和端口465