Hello,

I have been having some real compatibility issues with my email format.

I started sending just HTML emails to all my members but got complaints that some couldn't read them. As a result I recoded the email to send multipart text/html messages.

Again in came flooding emails saying that they couldn't read the message.

Whats the best solution. Really want to avoid plain text if at all possible.

Here is my code:

function emailTemplate($message, $subject, $fromEmail, $fromName, $toEmail, $toName){

global $site_url,$site_url,$root_dir,$artist,$bccEmail;

$filename = $root_dir."/styles/emailStyle.css";
$handle = fopen($filename, "r");
$css = fread($handle, filesize($filename));
fclose($handle);
$style = "<STYLE type=text/css>\r\n.".$css."</style>\r\n"; 

$htmlBody = $style."<table width=\"450\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"tblContentBox\">
<tr> 
    <td background='".$site_url."/images/email/logobg.gif' colspan=\"2\">
	<a href='".$site_url."'><img src='".$site_url."/images/email/logo.gif' border='0' alt='Click to visit the xxxxxxxxx' href='http://www.xxxxxx.org'></a>
	</td>
  </tr>
  <tr> 
    <td width=\"50%\"><span class='txtContentCopy'>";

if($toName!==" "){
$htmlBody .= "Dear ".$toName.",";
} else {
$htmlBody .= "Dear Member,"; 
}

$htmlBody .= "</span></td>
<td width=\"50%\" align=\"right\"><span class='txtContentCopy'>".date("jS F 'y")."</span></td>
  </tr>
  <tr> 
    <td colspan=\"2\"><br> 
      <p><span class='txtContentCopy'>".$message."</span></p>
      <p><span class='txtContentCopy'>Kind regards,</span></p>
      <p>&nbsp;</p>
      <p><span class='txtContentCopy'>".$artist."</span></p>
	  </td>
	 </tr>
	 <tr> 
    <td colspan=\"2\"><span class='txtContentCopy'>
	<hr size=1>
    To be removed from all future Global Ideas Bank emails, click</span> <a href=\"".$site_url."/site/members/unsubscribe.php\" class=\"txtCopyrightBtm\">here</a>.
	  </td>
  </tr>
</table>";

if($toName!==" "){
	$textBody = "Dear ".$toName.",\r\n\r\n";
	} else {
	$textBody = "Dear Member,\r\n\r\n"; }

$message = str_replace("<br>","\r\n",$message);
$message = str_replace("</p>","\r\n\r\n",$message);

$textBody .= strip_tags($message)."\r\n\r\nKind regards,\r\n\r\n".$artist."\r\n\r\nTo be removed from all future Global Ideas Bank emails, visit ".$site_url."/site/members/unsubscribe.php";


$headers = "Return-Path: [email]ideas@xxxxx.org[/email]\r\n"; 
$headers .= "From: ".$fromName." <".$fromEmail.">\r\n"; 
$headers .= "Reply-To: ".$fromName." <".$fromEmail.">\r\n";
$headers .= "X-Mailer: GIBMail\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("HTMLDEMO"); 
$headers .= "Content-Type: multipart/alternative" . 
   "; boundary = ".$boundary."\r\n\r\n"; 

$headers .= "This is a MIME encoded message.\r\n\r\n"; 

$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($textBody)); 

//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($htmlBody));   

mail($toEmail, $subject, "", $headers,"-f $fromEmail");
//mail($bccEmail, "GIBemail - ".$subject, "", $headers);
} 
    Write a Reply...