title: How to Add dynamic image on body of Email using phpmail
body: <p>I am creating a email service which send different image to different person using phpmail.I can send mail and attachment as i require but when it comes to dynamically adding embedded image in body of mail.
  I wont be able to achieve success.</p>
  
  <pre><code>&lt;?php
  
  require_once('class.phpmailer.php');
  
  // multiple recipients
  $to = $arr['Contact.Email']; // note the comma
  
  $mail = new PHPMailer(true); // the true param means it will throw exceptions on     errors, which we need to catch
  
  $mail-&gt;IsSMTP(); // telling the class to use SMTP
  try{
    $mail-&gt;SetFrom($arr['Contact.Email'], 'First Last');
    $mail-&gt;AddAddress($arr['Contact.Email'], 'John Doe');
    $mail-&gt;Subject = 'PHPMailer Test';
  
    $mail-&gt;AddEmbeddedImage($arr['ContactId'].'.png', 'my-attach');
  
    $mail-&gt;Body = 'Your &lt;b&gt;HTML&lt;/b&gt; with an embedded Image: &lt;img src=cid:my-attach\'&gt; Here is an image!';
  
    $mail-&gt;AddAttachment($arr['ContactId'].".png"); // this is a regular attachment (Not inline)
  
    $mail-&gt;Send();
    echo "Message Sent OK&lt;p&gt;&lt;/p&gt;\n";
  } 
  
  catch (phpmailerException $e) {
      echo $e-&gt;errorMessage(); //Pretty error messages from PHPMailer
  }
  
  catch (Exception $e) {
      echo $e-&gt;getMessage(); 
  }
  ?&gt;
  </code></pre>
  
  <p>I can embed one image but when i try to send different image for different user i get an error.I searched everywhere but i did not get any satisfactorily answer.
  any help will be appreciated.</p>