在 php.net 示例中mail()
,使用了两个不同的地址$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);
?>
所以我的问题是:你需要提供$to
的语法mail()
,但是你不能使用格式Name <email@domain.com>
,这你只能在附加的头信息中做,对吧?
那么首先,为什么 php.net 上的示例将邮件发送给 4 个不同的人(因为他们使用不同的电子邮件地址$to
和标题信息),这真的让我很生气!?
其次,如果我只想将邮件发送给 1 人(并且只有 1 次)并且我想使用 format Name <email@domain.com>
,我应该怎么做?使用它$to
以及标题信息?那么这个人会收到两次电子邮件吗?