我有一个我创建的表格,完成后他们被要求从下拉列表中选择他们希望通过电子邮件发送给的人。
我的问题是如何将该变量添加到 $mailer.
现在是这样写的
$mailer -> AddAddress('email@email.com','First Last');
我怎么把我的变量放在那里
$mailer -> AddAddress($emailAddress) - Doesn't work.
我也试过
"'"$emailAddress"'"
- 这给了我 - 无效地址:'email@email.com' 这令人沮丧,因为这是它正在寻找的格式。
谢谢,告诉我
这是我用来调用电子邮件的完整代码
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "yourname@yourdomain"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->AddAddress('whoto@otherdomain.com', 'John Doe');
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo('name@yourdomain.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();