Jump to content

Sending Email Whit Embed Image In Message


madness69

Recommended Posts

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?

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; ?>--

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.