PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jdhorton77
Forum Commoner
Posts: 56 Joined: Tue Nov 07, 2006 3:29 pm
Location: Charlotte, NC
Post
by jdhorton77 » Tue Sep 18, 2007 8:23 pm
I have a problem with one of my pages not wanting to send out messages as HTML format. It does send messages as text, so I think it must be in my headers. Can someone look over them and let me know if I'm just missing something. Thanks in advance.
Code: Select all
$headers = 'Content-type: text/html;charset=iso-8859-1'."\r\n".
'MIME-Version: 1.0'."\r\n".
'From: someone <webadmin@somewhere.com>'."\r\n".
'To: '.$row['friendname'].' <'.$eaddress.'>'."\r\n";
// message code here
if(!mail($eaddress,$subject,$message,$headers)) echo "Error in mailing system.";
jdhorton77
Forum Commoner
Posts: 56 Joined: Tue Nov 07, 2006 3:29 pm
Location: Charlotte, NC
Post
by jdhorton77 » Tue Sep 18, 2007 8:47 pm
Not sure if the hosting company uses Swift or not. I would rather just use the mail function since I'm not going to be sending mass emails.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Sep 18, 2007 10:08 pm
The hosting company doesn't need to use Swiftmailer... you can choose that yourself.
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Wed Sep 19, 2007 4:44 am
I use the following to send HTML emails and it works perfectly
Code: Select all
$to = "someone@destination.tld";
$subject = "Something...";
$message="<html>";
$from = $emailVar;
//add From: header
$headers = "From: " . $emailVar. "\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
//unique boundary
$boundary = uniqid("HTMLDEMO");
//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/alternative" .
"; boundary = $boundary\r\n\r\n";
//message to people with clients who don't
//understand MIME
$headers .= "This is a MIME encoded message.\r\n\r\n";
//plain text version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("This is the plain text version!"));
//HTML version of message
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($message));
mail($to,$subject,$message,$headers,"-f $from");