显示名称而不是电子邮件的电子邮件标题的格式是什么? [英] What is the format for e-mail headers that display a name rather than the e-mail?

查看:191
本文介绍了显示名称而不是电子邮件的电子邮件标题的格式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个php脚本,它将使用mySQL数据库处理我的邮件列表,并且我已经有了大部分的地方。不幸的是,我似乎无法使标题正常工作,我不知道问题是什么。

I'm trying to create a php script that will handle a mailing list for me using a mySQL database, and I have most of it in place. Unfortunately, I can't seem to get the headers to work right, and I'm not sure what the problem is.

$headers='From: noreply@rilburskryler.net \r\n';
$headers.='Reply-To: noreply@rilburskryler.net\r\n';
$headers.='X-Mailer: PHP/' . phpversion().'\r\n';
$headers.= 'MIME-Version: 1.0' . "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1 \r\n';
$headers.= "BCC: $emailList";

我收到的结果是:

noreply@ rilburskryler.net rnReply-To:noreply@rilburskryler.netrnX-Mailer:PHP / 5.2.13rnMIME-Version:1.0

"noreply"@rilburskryler.net rnReply-To: noreply@rilburskryler.netrnX-Mailer: PHP/5.2.13rnMIME-Version: 1.0

推荐答案

要显示姓名,而不是使用以下电子邮件地址:

To have names, as opposed to email addresses shown, use the following:

"John Smith" <johnsemail@hisserver.com>

简单

关于虚线这是因为你用撇号而不是引号括起文本:

Regarding the broken line breaks, that is because you are enclosing the text in apostrophes rather than quotation marks:

$headers = array(
  'From: "The Sending Name" <noreply@rilburskryler.net>' ,
  'Reply-To: "The Reply To Name" <noreply@rilburskryler.net>' ,
  'X-Mailer: PHP/' . phpversion() ,
  'MIME-Version: 1.0' ,
  'Content-type: text/html; charset=iso-8859-1' ,
  'BCC: ' . $emailList
);
$headers = implode( "\r\n" , $headers );

这篇关于显示名称而不是电子邮件的电子邮件标题的格式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆