【发布时间】:2012-08-09 15:26:37
【问题描述】:
在mail() 的php.net 示例中,$to 使用了两个不同的地址以及附加的标题信息“To: ...”:
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
$subject = 'Birthday Reminders for August';
// message
$message = '<html> ... </html>';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
所以我的问题是:mail()的语法你需要提供$to,但是你不能使用Name <email@domain.com>的格式,你只能在附加的头信息中这样做,对吧?
首先,为什么 php.net 上的示例将邮件发送给 4 个不同的人(因为他们对 $to 和标题信息使用不同的电子邮件地址),这真的让我很生气!?
其次,如果我只想将邮件发送给 1 人(并且只有 1 次)并且我想使用格式 Name <email@domain.com>,我应该怎么做?在$to 以及标题信息中使用它?然后此人会收到两次电子邮件吗?
【问题讨论】:
标签: php email html-email email-headers