ssatish4u
ssatish4u

Reputation: 131

image not showing in email using php mail

I am trying to send email using php code mail is working file but image not coming into the mail. the image src path is coming with encoded string as below

<img style="width:100%" src="https://ci6.googleusercontent.com/proxy/NT6fQckS1LLRnuTUJnW0Fp2qUujk_Cpv9kV1hwoKQADwL8XU7fo4=s0-d-e1-ft#http://header.png" class="CToWUd a6T" tabindex="0">

<?php
        $to = $_REQUEST['email'];
        $subject = 'Winning prize';
        $email_id =  '[email protected]';
        $headers = "From: " . strip_tags($email_id) . "\r\n";
        $headers .= "Reply-To: " . strip_tags($email_id) . "\r\n";
        $headers .= "CC: [email protected]";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
      $message = '<html>
       <head>
          <title></title>
       </head>
       <body>
          <div style="border:1px solid #e96000; width: 600px;">
          <table style="color: #777;font-family: sans-serif;" width="600">
             <tr>
                <td style="padding:0px 0">
                   <img style="width: 100%;" src="header.png">
                </td>
             </tr>
             <tr>
                <td><span style="font-family: sans-serif;">Hey</span><span style="font-family: sans-serif;margin-left: 5px;">'.$address['customer_name'].'!,</span></td>
             </tr>
             <tr>
                <td style="padding:20px 0 0 20px"><span style="font-family: sans-serif;">Congratualtion! The product is Yours.</span></td>
             </tr>

          </table>
          <table style="color: #777;font-family: sans-serif;text-align: center;" width="600">   
             <tr>
                <td colspan="4" style="padding: 30px 0;border-top: 1px solid #e96000;border-bottom: 1px solid #e96000;"><span>Once Your Package ships we will send your a tracking number Once Your Package ships we will send your a tracking number Once Your Package ships we will send your a tracking number </span></td>
             </tr>
          </table>
       </div>
       </body>
    </html>';
        $result = mail($to, $subject, $message, $headers);

?>

the above code is working file just image not coming into the mail

Upvotes: 0

Views: 1344

Answers (1)

azizsagi
azizsagi

Reputation: 276

Most of the email clients block the image. But still, you can show the image. You have to use Absolute image source URL. For an example

<img style="width: 100%;" src="header.png">

change to

<img style="width: 100%;" src="http://www.YourSite.com/header.png">

Please be sure that the image exists in the path.

Upvotes: 1

Related Questions