Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the format for e-mail headers that display a name rather than the e-mail?

Tags:

php

email

header

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: [email protected] \r\n'; $headers.='Reply-To: [email protected]\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"; 

The result I'm getting on the recieving end is:

"noreply"@rilburskryler.net rnReply-To: [email protected]: PHP/5.2.13rnMIME-Version: 1.0

like image 995
RonLugge Avatar asked Sep 04 '10 21:09

RonLugge


People also ask

What is an email header name?

An email header is the area in which you enter important information above the email content area. The information in the header includes such things as the recipient, the sender, and a subject line with the option of sending copies to additional recipients.

What are different email headers?

An email header tells who sent the email and where it arrived. Some markers indicate this information, like “From:” — sender's name and email address, “To:” — the recipient's name and email address, and “Date:” — the time and date of when the email was sent.


1 Answers

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

"John Smith" <[email protected]> 

Easy.

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" <[email protected]>' ,   'Reply-To: "The Reply To Name" <[email protected]>' ,   'X-Mailer: PHP/' . phpversion() ,   'MIME-Version: 1.0' ,   'Content-type: text/html; charset=iso-8859-1' ,   'BCC: ' . $emailList ); $headers = implode( "\r\n" , $headers ); 
like image 150
Luke Stevenson Avatar answered Oct 14 '22 05:10

Luke Stevenson