madness69 Posted October 19, 2012 Share Posted October 19, 2012 Hi there, im fixing my email newsletter, and works fine, but there is a problem, in my message box when i embed a image, when i receive the email it spits code: The Code that was spited out is: --PHP-mixed-32cf48ccffb0b0d4910da883d1582f20 Content-Type: multipart/alternative; boundary="PHP-alt-32cf48ccffb0b0d4910da883d1582f20" --PHP-alt-32cf48ccffb0b0d4910da883d1582f20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Text email message. --PHP-alt-32cf48ccffb0b0d4910da883d1582f20 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <p> <p><img style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"http://google some image\" alt=\"\" width=\"437\" height=\"496\" /></p></p> --PHP-alt-32cf48ccffb0b0d4910da883d1582f20-- --PHP-mixed---PHP-mixed-32cf48ccffb0b0d4910da883d1582f20-- And the original code of this part is: $random_hash = md5(date('r', time())); $headers = "From: " . $from . "\r\nReply-To: " . $from . " \r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"\r\n"; $headers .= 'X-Mailer: PHP/' . phpversion(); if ($anexo=="sim") { $attachment = chunk_split(base64_encode(file_get_contents($path_file))); } ob_start(); //Turn on output buffering ?> --PHP-mixed-<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Text email message. --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <p> <?php echo $msg; ?></p> --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php if ($anexo=="sim") { echo $random_hash; ?> Content-Type: application/zip; name="<?php echo $file_name; ?>" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; } ?> --PHP-mixed-<?php echo $random_hash; ?>-- Do someone no what is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/269684-sending-email-whit-embed-image-in-message/ Share on other sites More sharing options...
DavidAM Posted October 19, 2012 Share Posted October 19, 2012 That is exactly what you told it to do if $anexo is not equal to "sim". My guess is that that variable is not getting set to what you think it should be. Also, see my comment in the first line below --PHP-mixed-<?php ## NOTE: This should be INSIDE the IF below if ($anexo=="sim") { echo $random_hash; ?> Content-Type: application/zip; name="<?php echo $file_name; ?>" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; } ?> --PHP-mixed-<?php echo $random_hash; ?>-- Quote Link to comment https://forums.phpfreaks.com/topic/269684-sending-email-whit-embed-image-in-message/#findComment-1386394 Share on other sites More sharing options...
madness69 Posted October 21, 2012 Author Share Posted October 21, 2012 it doesnt work, still the same Quote Link to comment https://forums.phpfreaks.com/topic/269684-sending-email-whit-embed-image-in-message/#findComment-1386804 Share on other sites More sharing options...
DavidAM Posted October 22, 2012 Share Posted October 22, 2012 it doesnt work, still the same What did you change? Show your revised code and tell us what it is doing? Try echo (or var_dump()) on $anexo to see if it is what you expect. Quote Link to comment https://forums.phpfreaks.com/topic/269684-sending-email-whit-embed-image-in-message/#findComment-1387079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.