{"id":539,"date":"2010-03-05T15:24:11","date_gmt":"2010-03-05T14:24:11","guid":{"rendered":"http:\/\/www.dotmana.com\/index.php\/?p=539"},"modified":"2010-03-05T15:24:11","modified_gmt":"2010-03-05T14:24:11","slug":"phpmailer-inline-image-seen-as-attachment","status":"publish","type":"post","link":"https:\/\/www.dotmana.com\/weblog\/2010\/03\/phpmailer-inline-image-seen-as-attachment\/","title":{"rendered":"PHPMailer : inline image seen as attachment"},"content":{"rendered":"<p>There is an issue with PHPMailer and AddEmbeddedImage method.<\/p>\n<p>In some email client, you will get image as an attachment and not inline as expected.<\/p>\n<p>To fix that, patch the class.phpmailer.php with following :<\/p>\n<blockquote><p>$disposition = $this-&gt;attachment[$i][6];<br \/>\n$cid\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = $this-&gt;attachment[$i][7];<\/p>\n<p>\/\/ patch<br \/>\n$path_parts = pathinfo($filename);<br \/>\n$extension = $path_parts[&#8216;extension&#8217;];<br \/>\n\/\/ end patch<\/p>\n<p>$mime[] = sprintf(&#8220;&#8211;%s%s&#8221;, $this-&gt;boundary[1], $this-&gt;LE);<\/p>\n<p>\/\/ patch<br \/>\n\/\/$mime[] = sprintf(&#8220;Content-Type: %s; name=\\&#8221;%s\\&#8221;%s&#8221;, $type, $name, $this-&gt;LE);<br \/>\n$mime[] = sprintf(&#8220;Content-Type: image\/&#8221;.$extension.&#8221;;\\n&#8221;);<br \/>\n\/\/ end patch<br \/>\n$mime[] = sprintf(&#8220;Content-Transfer-Encoding: %s%s&#8221;, $encoding, $this-&gt;LE);<\/p>\n<p>if($disposition == &#8220;inline&#8221;)<br \/>\n$mime[] = sprintf(&#8220;Content-ID: &lt;%s&gt;%s&#8221;, $cid, $this-&gt;LE);<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>There is an issue with PHPMailer and AddEmbeddedImage method. In some email client, you will get image as an attachment and not inline as expected. To fix that, patch the class.phpmailer.php with following : $disposition = $this-&gt;attachment[$i][6]; $cid\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 = $this-&gt;attachment[$i][7]; &hellip; <a href=\"https:\/\/www.dotmana.com\/weblog\/2010\/03\/phpmailer-inline-image-seen-as-attachment\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-539","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":1,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":540,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/539\/revisions\/540"}],"wp:attachment":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/categories?post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/tags?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}