如何使用没有服务器名称的带有发件人姓名和电子邮件地址的 php 发送电子邮件


How to send email using php with sender name and email address by without server name?

如何使用没有服务器名称的带有发件人姓名和电子邮件地址的php发送电子邮件?

我想发送姓名:NUMBERONE和电子邮件地址:admin@NUMBERONE.com

的电子邮件
    $headers  = 'MIME-Version: 1.0' . "'r'n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
    $headers .= "From:NUMBERONE(admin@NUMBERONE.com)'r'n"; 
    mail($to, $subject, $message, $headers);

我尝试上面的代码,它不是发送电子邮件。我该怎么做?

PHP mail() 函数文档中的示例 #4 回答了您的问题。

// 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";

在您的情况下,它应该是:

$headers .= 'From: NUMBERONE <admin@NUMBERONE.com>' . "'r'n";