![](/img/trans.png)
[英]Using a sender's name and email address in the header of a PHP email form
[英]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";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.