我有一个我创建的表单,完成后他们被要求从下拉列表中选择他们希望通过电子邮件发送的人。使用PHPMailer发送电子邮件到变量地址
我的问题是如何将该变量添加到$邮件程序。
现在它是这样写的
$mailer -> AddAddress('[email protected]','First Last');
如何让我的变量有
$mailer -> AddAddress($emailAddress) - Doesn't work.
我也试过
"'"$emailAddress"'"
- 这给了我 - 无效地址:'[email protected]'这是令人沮丧的,因为这是它正在寻找的格式。
谢谢你,让我知道
这里是我使用调用邮件
$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 = "[email protected]"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo('[email protected]', '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();
$ mailer-> AddAddress($ emailAddress);应该工作,如果$ emailAddress =“[email protected]”;你试过在$ mailer-> AddAddress($ emailAddress)附近的代码中回显$ emailAddess; ?你能告诉我们什么“不起作用”? – Shikiryu 2010-09-28 13:20:47
我做了回声,然后页面崩溃。我也试着在html下拉单引号中使用一个变量,然后调用$ mailer中的变量,但也没有奏效。 我每次使用除特定('[email protected]')以外的任何地址时都会收到无效地址。 – FixingGenie 2010-09-28 13:41:05
我也尝试过使用ASCII码来调用同样在值中产生\的单引号。 ' 我还没有试过 还没有,但我现在就试试。 – FixingGenie 2010-09-28 13:49:17