Mailer错误:无法为php Mailer函数实例化邮件函数


Mailer error: Could not instantiate mail function for php mailer function

我想使用xampp发送邮件。所以我使用了phpmailer函数。但我得到了这些错误"Mailer错误:无法实例化邮件函数"。我的php代码遵循

$mail = new PHPMailer();
$mail->Host     = "localhost"; // SMTP server
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = "myothantspo@gmail.com";
$mail->Password = "password";
$mail->From     = "myothantspo@gmail.com";
$mail->AddAddress("webdev3@myanmars.net");
$mail->Subject  = "no subject";
$mail->Body     = "this is a test message";
if(!$mail->Send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}

php.ini的设置如下

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = myothantspo@gmail.com

您的大多数配置(HostPortSMTPAuth等)与PHPMailer自己的SMTP处理程序有关,而不是与PHP内置的mail函数有关。

因此,如果您希望PHPMailer使用SMTP而不是mail发送电子邮件,那么在调用$mail->Send()之前,您需要在代码中添加$mail->IsSMTP();

是否包含phpmailer?像这样:

require 'PHPMailerAutoload.php';

或者你可能想检查一下:

https://github.com/PHPMailer/PHPMailer