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

时间:2016-04-08 12:31:29

标签: 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';
}

1 个答案:

答案 0 :(得分:3)

您在方法中错过了一个 d 使用$m->AddAddress(recipientMailAddress [, recipientName]);