<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>anty.info &#187; inline images</title>
	<atom:link href="http://www.anty.info/tag/inline-images/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anty.info</link>
	<description>Comments and help on web development.</description>
	<lastBuildDate>Fri, 11 Jun 2010 14:50:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Zend_Mail Obstacles</title>
		<link>http://www.anty.info/2008/02/18/zend_mail-obstacles/</link>
		<comments>http://www.anty.info/2008/02/18/zend_mail-obstacles/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 18:41:34 +0000</pubDate>
		<dc:creator>anty</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[inline images]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Mime]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Mail]]></category>
		<category><![CDATA[Zend_Mime]]></category>

		<guid isPermaLink="false">http://www.anty.info/2008/02/18/zend_mail-obstacles/</guid>
		<description><![CDATA[I just finished developing a newsletter-script for a client. I encountered some problems during the development and want to publish the solutions here. I used Zend_Mail and Zend_Mime to create HTML-mails with inline images. I used the last stable Zend Framework version available right now: 1.0.3. Microsoft Outlook 2007 displays odd characters, Thunderbird doesn&#8217;t Check [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished developing a newsletter-script for a client.<br />
I encountered some problems during the development and want to publish the solutions here.</p>
<p><span id="more-10"></span></p>
<p>I used <a href="http://framework.zend.com/manual/en/zend.mail.html">Zend_Mail</a> and <a href="http://framework.zend.com/manual/en/zend.mime.html">Zend_Mime</a> to create HTML-mails with inline images. I used the last stable <a href="http://framework.zend.com">Zend Framework</a> version available right now: 1.0.3.</p>
<h3>Microsoft Outlook 2007 displays odd characters, Thunderbird doesn&#8217;t</h3>
<p>Check if you use:<br />
<code class="prettyprint">new Zend_Mail('utf8');</code><br />
If you do, change it to:<br />
<code class="prettyprint">new Zend_Mail('utf-8');</code><br />
Outlook doesn&#8217;t like the non-dashed version of the UTF-8 charset.</p>
<h3>Inline images are displayed as attachments</h3>
<p>You need to set the type of the mail to Multipart/Related:<br />
<code class="prettyprint">$mail-&gt;setType(Zend_Mime::MULTIPART_RELATED);</code><br />
Add the images like this:<br />
<code class="prettyprint">$mail-&gt;createAttachment($imageData, $imageType, Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64);</code><br />
Add the HTML-Version of the mail like this:<br />
<code class="prettyprint">$mail-&gt;setBodyHtml($htmlMessage, null, Zend_Mime::MULTIPART_RELATED);</code></p>
<h3>The subject displays odd characters</h3>
<p>There&#8217;s a <a href="http://framework.zend.com/issues/browse/ZF-2532" title="Wrong encoded of the subject, if the subject is longer than Zend_Mime::LINELENGTH">bug in Zend_Mail</a> that causes subjects longer than 200 characters to be malformed in the mail. It&#8217;s also causing problems in the Zend Framework version 1.5 preview. The solution is to use subjects shorter than 200 characters until a fix is integrated in Zend_Mail.</p>
<h3>Zend_Mail throws a 501 exception on international mail-addresses</h3>
<p>If your email addresses are pointing to domains like hpphör.de, your SMTP-server might prevent you from sending to them, causing Zend_Mail to throw a 501 exception. <a href="http://www.nabble.com/Re%3A-Zend_Mail---Zend_Mail_Transport_Smtp-Problems-p11294914s16154.html" title="Zend_Mail &amp; Zend_Mail_Transport_Smtp Problems">A possible solution</a> is to convert the domainname to the <a href="http://en.wikipedia.org/wiki/Internationalized_domain_name" title="Internationalized Domain Name">IDN</a> equivalent (hpphör.de results in xn--hpphr-mua.de). Currently, there is no ZendFramework module available to do the conversion. Maybe the <a href="http://pecl.php.net/package/idn">IDN Pecl package</a> can help you on this subject.</p>
<p><strong>Note:</strong> Malformed mail addresses also cause a 501 exception to be thrown. Catching a 501 exception does not guarantee an IDN domain-address!</p>
<h3>The HTML layout is totally messed up</h3>
<p>Don&#8217;t use CSS for styling, go back to Table-based styling. Most mail-clients still don&#8217;t display HTML correctly. Use inline-style definitions, even though they produce redundant code.</p>
<p>Get more information on HTML mail styling here:</p>
<ul>
<li><a href="http://www.sitepoint.com/article/code-html-email-newsletters">How to Code HTML Email Newsletters</a></li>
<li><a href="http://www.campaignmonitor.com/blog/archives/2006/03/a_guide_to_css_1.html">A Guide to CSS Support in Email</a></li>
</ul>
<p>I hope this helps a bit if you find yourself in the position to code a PHP mail-script.</p>
<p>At <a href="http://www.sitepoint.com">SitePoint</a> I found a very good article that covers <a href="http://www.sitepoint.com/article/principles-beautiful-html-email" title="The Principles of Beautiful HTML Email">how to design HTML mails from the content point of view</a>. I recommend to read the first two pages if you need to write the content by yourself!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anty.info/2008/02/18/zend_mail-obstacles/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
