dj-kenpo Posted December 1, 2008 Share Posted December 1, 2008 not sure what I am doing wrong. I am trying to send an email and I can send the html part, and the image works INLINE as a background, but I CANNOT get the text/plain background alternate version to work at all. it just shows up as an attachment or not at all can anyone see what I am doing wrong??? -------------------- $headers = "From: me <$admin_email>\r\n"; $headers .= "Reply-To: $admin_email\r\n"; $headers .= "Return-Path: $admin_email\r\n"; $headers .= "MIME-Version: 1.0 "."\n"; $headers .= "Content-Type: multipart/related; boundary=\"multipart_related_boundary\" This is a multi-part message in MIME format."; $inline = chunk_split(base64_encode(file_get_contents("image.jpg"))); ob_start(); //Turn on output buffering ?> --multipart_related_boundary Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <style type="text/css"> <!-- .style2 {font-family: Georgia, "Times New Roman", Times, serif; color: #5D6568; font-size: 18px; } a {font-family: Georgia, "Times New Roman", Times, serif; color: #5D6568; font-size: 12px; font-weight: bold;} --> </style> </head> <body bgcolor="#ffffff" text="#000000"> <table width="600" height="500" border="0" cellpadding="0" cellspacing="0" background="cid:image_identifier"> <tr> <td width="108" height="165"> </td> <td width="319"> </td> <td width="173"> </td> </tr> <tr> <td height="25"> </td> <td><div align="center" class="style2"><? print "$fromFirstName $fromLastName"; ?></div></td> <td> </td> </tr> <tr> <td height="90"> </td> <td> </td> <td> </td> </tr> <tr> <td height="23"> </td> <td width="319"><div align="center"> <a href="http://<? print $link; ?>">Click Here</a> </div></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </body> </html> --multipart_related_boundary Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit this is the plain version of the message that is not working --multipart_related_boundary Content-Type: image/jpeg; name="email_back.jpg" Content-Transfer-Encoding: base64 Content-ID: <image_identifier> Content-Disposition: inline; filename="email_back.jpg" <? print $inline; ?> --multipart_related_boundary-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail($toEmail, $Subject, $message, $headers); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Mail sent&" : "Mail failed&"; Link to comment https://forums.phpfreaks.com/topic/135005-multipart-mail-not-working-right/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.