在mail.net的PHP.net示例中,两个不同的地址用于$to和附加的头信息“To:…”:
<?PHP // multiple recipients $to = '[email protected]' . ','; // note the comma $to .= '[email protected]'; $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 <[email protected]>,Kelly <[email protected]>' . "\r\n"; $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; $headers .= 'Cc: [email protected]' . "\r\n"; $headers .= 'Bcc: [email protected]' . "\r\n"; // Mail it mail($to,$subject,$message,$headers); ?>
所以我的问题是:你需要为mail()的语法提供$to,但是你不能使用格式Name< [email protected]\u0026gt;,这只能在附加的头信息中做,对吧? 首先,为什么PHP.net上的示例会将邮件发送给4个不同的人(因为他们使用不同的电子邮件地址来获取$to和标题信息),这真的让我很恼火!? 其次,如果我想将邮件仅发送给1个人(并且只有1次),并且我想使用格式名称< [email protected]\u0026gt;,我应该怎么做?在$to中使用它以及标题信息?然后这个人会收到两次电子邮件吗?