简体   繁体   中英

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

I want to sent mail by using xampp.So I used phpmailer function.But I got these error "Mailer error: Could not instantiate mail function". My php code is following

$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.';

}

My setting for php.ini is following

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = myothantspo@gmail.com

Most of your configuration ( Host , Port , SMTPAuth etc) relates to PHPMailer's own SMTP handler rather than PHP's built-in mail function.

If, as it therefore appears, you want PHPMailer to send email using SMTP instead of mail then you need to add $mail->IsSMTP(); to your code somewhere before you call $mail->Send() .

Did you include phpmailer? Like this:

require 'PHPMailerAutoload.php';

Or you might want to check this:

https://github.com/PHPMailer/PHPMailer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM