如何修复未定义方法 PHPMailer::AddAdress() 错误?

Sti*_*hof 4 php phpmailer

我正在制作一个 PHP 邮件脚本,并且使用 phpmailer。我收到错误:

致命错误:调用 PHPMailer::AddAdress() 中未定义的方法

这是我的代码:

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';
}
Run Code Online (Sandbox Code Playgroud)

Hal*_*nis 5

你的方法中漏掉了一个d
使用$m->AddAddress(recipientMailAddress [, recipientName]);