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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.