致命错误:未捕获错误:调用 F:\WebServer\htdocs\Module15\index

我正在使用 phpMailer 自动向特定用户发送邮件,但它向我抛出错误“致命错误:未捕获错误:调用 F:\WebServer\htdocs\Module15\index.php:14 中未定义的方法 PHPMailer::setForm()堆栈跟踪:#0 {main} 抛出”。谁能帮我解决这个问题。


这是我的代码:


索引.php


<?php  

require 'phpmailer/PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->isSMTP();

$mail -> SMTPDebug = 1;

$mail->HOST='smpt.gmail.com';

$mail->Port=587;

$mail->SMTPAuth=true;

$mail->SMTPSecure='tls'

$mail->Username='name@gmail.com';

$mail->Password='444';

$mail->setForm('name@gmail.com', 'Tariq Shaikh');

$mail->addAddress('name1@gmail.com');

$mail->addReplyTo('name@gmail.com');

$mail->isHTML(true);

$mail->Subject='Notification';

$mail->Body='<h2 align=center>A new Audit Form has been Uploaded by Faculty.</h2><h3 align=center>Please check your Notification</h3>';


if (!$mail->send()) {

    echo "ERROR! Email is not sent!";

}

else{

    echo "Email has been sent successfully";

}

?>


largeQ
浏览 105回答 1
1回答

慕妹3242003

你有一个错字它$mail->setFrom()代替了$mail->setForm()
打开App,查看更多内容
随时随地看视频慕课网APP