| Recommend this page to a friend! | 
| MIME E-mail message sending | > | MIME E-mail message sending package blog | > | How Can PHP Send Emai... | > | All threads | > | html email | > | (Un) Subscribe thread alerts | 
| 
 | |||||||||||||||
| 1 - 10 | 11 - 11 | 
| 
  Pascal Clerin - 2007-04-13 13:59:50 I am trying to send html email. This html email has a table, somes images, and some of these images are background. When I receive the email, everything is ok, but the background images are not visible... I have followed the example of the file test_html_mail_message.php, and with this example there is the same problem ($background_image_content_id is not visible...) Any help will be welcome Thank you Pascal 
  Manuel Lemos - 2007-04-13 18:48:15 - In reply to message 1 from Pascal Clerin What do you mean they are not visible? Is your mail program blocking the images, or the images appear broken? 
  Pascal Clerin - 2007-04-13 20:58:53 - In reply to message 2 from Manuel Lemos The images that are background (ie background of table cells, or background in body tag) do not appear. The images displayed directly are visible, here is the code: $html_message="<html><head> <title></title> </head> <body> <table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=center> <tr valign=\"top\"> <td colspan=\"3\"><img src=\"cid:".$image1_content_id."\" /></td> </tr> <tr valign=\"top\"> <td width=\"68\" style=\"background-color:#BEE4F1\"><img src=\"cid:".$image2_content_id."\" /></td> <td width=\"675\" rowspan=\"3\" valign=\"top\" style=\"background-image: url(cid:".$image4_content_id.")\" style=\"text-align:justify\" style=\"font-size:12px\">".$message."</td> <td width=\"57\" style=\"background-color:#56B7DA\"><img src=\"cid:".$image3_content_id."\" /></td> </tr> <tr valign=\"top\"> <td class=\"izquierda\" style=\"background-color:#BEE4F1\" style=\"background-image: url(cid:".$image8_content_id.")\" style=\"background-repeat:repeat\"> </td> <td class=\"derecha\" style=\"background-color:#56B7DA\" style=\"background-image: url(cid:".$image9_content_id.")\" style=\"background-repeat:repeat\"> </td> </tr> <tr valign=\"bottom\"> <td class=\"izquierda\" style=\"background-color:#BEE4F1\"><img src=\"cid:".$image5_content_id."\" /></td> <td class=\"derecha\" style=\"background-color:#56B7DA\"><img src=\"cid:".$image6_content_id."\" /></td> </tr> <tr valign=\"top\"> <td colspan=\"3\"><img src=\"cid:".$image7_content_id."\" /></td> </tr> </table> </body> </html>"; The images identified by $image4_content_id, $image8_content_id, $image9_content_id are not displayed, but are loaded in the email. The other ones are displayed correctly. I have tried with to read the email with gmail, hotmail, and some other, and the problem is the same. Pascal 
  Manuel Lemos - 2007-04-13 21:37:53 - In reply to message 3 from Pascal Clerin And how are you defining the variables that you use to define the images? Can you send a sample message to my e-mail address? (use the e-mail contact link in the class page). 
  Pascal Clerin - 2007-04-17 11:47:04 - In reply to message 4 from Manuel Lemos Manuel, Here is the code of the function that organizes and send the email: function envio_mensaje_html_formato($idio_cod_idio_dest,$email_dest,$to_name,$mensaje,$titulos,$archivo='',$from_name= EMAIL_INFO,$from_address= EMAIL_INFO) { global $DOC_ROOT; require_once($DOC_ROOT."/clases/mimemessage/email_message.php"); $reply_name=$from_name; $reply_address=$from_address; $error_delivery_name=$from_name; $error_delivery_address=$from_address; $subject=$titulos[$idio_cod_idio_dest]; $email_message=new email_message_class; if ($_SERVER['SERVER_NAME']!='localhost' && $_SERVER['SERVER_NAME']!='192.168.0.3') { $to_address=$email_dest; // $email_message->SetEncodedEmailHeader("Bcc",EMAIL_WEBMASTER,$from_name); $email_message->SetMultipleEncodedEmailHeader('Bcc', array( EMAIL_WEBMASTER => $from_name, '[email protected]' => $from_name, '[email protected]' => $from_name, 'pcleringraffiti.net' => $from_name) ); } else { $to_address=EMAIL_DEV; $email_message->SetEncodedEmailHeader("Bcc",EMAIL_WEBMASTER,$from_name); } $email_message->SetEncodedEmailHeader("To",$to_address,$to_name); $email_message->SetEncodedEmailHeader("From",$from_address,$from_name); $email_message->SetEncodedEmailHeader("Reply-To",$reply_address,$reply_name); $email_message->SetHeader("Sender",$from_address); if(defined("PHP_OS") && strcmp(substr(PHP_OS,0,3),"WIN")) { $email_message->SetHeader("Return-Path",$error_delivery_address); } $email_message->SetEncodedEmailHeader("Errors-To",$error_delivery_address,$error_delivery_name); $email_message->SetEncodedHeader("Subject",$subject); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_top.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part1); $image1_content_id=$email_message->GetPartContentID($image_part1); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_izquierda_superior.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part2); $image2_content_id=$email_message->GetPartContentID($image_part2); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_derecha_superior.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part3); $image3_content_id=$email_message->GetPartContentID($image_part3); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_fondo.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part4); $image4_content_id=$email_message->GetPartContentID($image_part4); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_izquierda_inferior.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part5); $image5_content_id=$email_message->GetPartContentID($image_part5); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_derecha_inferior.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part6); $image6_content_id=$email_message->GetPartContentID($image_part6); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/incl/mail_bottom.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part7); $image7_content_id=$email_message->GetPartContentID($image_part7); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_izquierda_banda.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part8); $image8_content_id=$email_message->GetPartContentID($image_part8); $image=array( "FileName"=>"http://www.macrorruedasproexport.com/latinoamerica2007/img/mail_derecha_banda.jpg", "Content-Type"=>"automatic/name", "Disposition"=>"inline" ); $email_message->CreateFilePart($image,$image_part9); $image9_content_id=$email_message->GetPartContentID($image_part9); $message=nl2br(htmlentities($mensaje)); $html_message="<html><head> <title></title> </head> <body> <table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=center> <tr valign=\"top\"> <td colspan=\"3\"><img src=\"cid:".$image1_content_id."\" /></td> </tr> <tr valign=\"top\"> <td width=\"68\" style=\"background-color:#BEE4F1\"><img src=\"cid:".$image2_content_id."\" /></td> <td width=\"675\" rowspan=\"3\" valign=\"top\" style=\"background-image: url(cid:".$image4_content_id.")\" style=\"text-align:justify\" style=\"font-size:12px\">".$message."</td> <td width=\"57\" style=\"background-color:#56B7DA\"><img src=\"cid:".$image3_content_id."\" /></td> </tr> <tr valign=\"top\"> <td class=\"izquierda\" style=\"background-color:#BEE4F1\" style=\"background-image: url(cid:".$image8_content_id.")\" style=\"background-repeat:repeat\"> </td> <td class=\"derecha\" style=\"background-color:#56B7DA\" style=\"background-image: url(cid:".$image9_content_id.")\" style=\"background-repeat:repeat\"> </td> </tr> <tr valign=\"bottom\"> <td class=\"izquierda\" style=\"background-color:#BEE4F1\"><img src=\"cid:".$image5_content_id."\" /></td> <td class=\"derecha\" style=\"background-color:#56B7DA\"><img src=\"cid:".$image6_content_id."\" /></td> </tr> <tr valign=\"top\"> <td colspan=\"3\"><img src=\"cid:".$image7_content_id."\" /></td> </tr> </table> </body> </html>"; $email_message->CreateQuotedPrintableHTMLPart($html_message,"",$html_part); $related_parts=array( $html_part, $image_part1, $image_part2, $image_part3, $image_part4, $image_part5, $image_part6, $image_part7, $image_part8, $image_part9 ); $email_message->CreateRelatedMultipart($related_parts,$html_parts); $text_message="This is an HTML message. Please use an HTML capable mail program to read this message."; $email_message->CreateQuotedPrintableTextPart($email_message->WrapText($text_message),"",$text_part); $alternative_parts=array($text_part,$html_parts); $email_message->AddAlternativeMultipart($alternative_parts); $attachment=array( "Data"=>"Archivo texto del mensaje / Text file of this message", "Name"=>$mensaje, "Content-Type"=>"automatic/name", "Disposition"=>"attachment" ); $email_message->AddFilePart($attachment); $error=$email_message->Send(); if (strcmp($error,"")) { $madate_larga=strftime("%Y")."-".strftime("%m")."-".strftime("%d")." ".strftime("%H").":".strftime("%M").":".strftime("%S"); $sql='INSERT INTO errores_mails_enviados (destinatario,email,objeto,cuerpo,error,fecha) '; $sql.='VALUES ("'.$to_name.'","'.$to_address.'","'.$subject.'","'.$mensaje.'","'.$error.'","'.$madate_larga.'")'; $result = mysql_query ($sql) or die ("func_envio_mensajes.inc.php: $sql falla"); } return TRUE; } There is a warning generated for each image loaded in this code, here is an example: <errorentry> <datetime>2007-04-17 02:45:12 (CEST)</datetime> <errornum>2</errornum> <errortype>Alerte</errortype> <errormsg>filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for macrorruedasproexport.com/latinoame...<scriptname>/home/macrorue/www/latinoamerica2007/clases/mimemessage/email_message.php</scriptname> <scriptlinenum>803</scriptlinenum> </errorentry> 
  Manuel Lemos - 2007-04-17 22:22:15 - In reply to message 5 from Pascal Clerin It seems the problem is that your PHP setup is not with magic_quotes_runtime on and PHP is not able to retrieve remote file size. This combination of situations was exposing a bug in the class. I just uploaded a fixed version. Just let me know if it works now. 
  Pascal Clerin - 2007-04-18 23:29:14 - In reply to message 6 from Manuel Lemos I have installed the fixed script, but it goes on... 
  Manuel Lemos - 2007-04-19 07:09:52 - In reply to message 7 from Pascal Clerin I have been knocking my head just to realize there is no bug. The images that do not display are only those use as background images. For security reasons most modern browser programs do not display backgrounds defined by images, as those images may confuse the users. Just do not use images as backgrounds and the message will be displayed correctly. You can use background colors though. 
  Helge Orthmann - 2007-04-23 13:46:10 - In reply to message 8 from Manuel Lemos You can use the old code "background" for this like <td background=''> instead of <td style='backgound-image:...'> 
  Cleon Fernandes - 2008-02-01 17:26:47 - In reply to message 9 from Helge Orthmann I know this is an old issue, but have you managed it? I've tried everyting, I just can't put it work, background images just don't appear, instead mail clients show them as attachment, even though we set "inline". Thank you very much. Cleon | 
| 1 - 10 | 11 - 11 | 
info at phpclasses dot org.
