How to fix undefined method PHPMailer::AddAdress() error?

一世执手 提交于 2019-12-11 00:38:50

问题


I am making a PHP mail script, and I'm using phpmailer for it. I get the error:

Fatal error: Call to undefined method PHPMailer::AddAdress() in

This is my code:

if (empty($errors)) {

$m = new PHPMailer;

$m->isSMTP();
$m->SMTPAuth = true;

$m->SMTPdebug = 2;

$m->Host = 'smtp.gmail.com';
$m->Username = 'email@gmail.com';
$m->Password = '******'
$m->SMTPSecure = 'tls';
$m->Port = 465;

$m->isHTML();

$m->Subject = 'Contact form submitted';
$m->Body = 'From: ' . $fields['name'] . ' (' . $fields['email'] . ')<p>' . $fields['message'] . '</p>';

$m->FromName = 'Contact';

$m->AddAdress("email@gmail.com", "Name");

if ($m->send()) {
    header('Location: thanks.php');
    die();
} else {
 $errors[] = 'sorry, could not send';
}

回答1:


You've missed one d in your method
Use $m->AddAddress(recipientMailAddress [, recipientName]);



来源:https://stackoverflow.com/questions/36499642/how-to-fix-undefined-method-phpmaileraddadress-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!