<?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>Apelog &#187; document</title>
	<atom:link href="http://blog.apecell.com/tag/document/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.apecell.com</link>
	<description>Apecell's blog by Design</description>
	<lastBuildDate>Tue, 22 Jun 2010 07:08:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Zend Framework &#8211; Zend_Mailのドキュメントの間違い</title>
		<link>http://blog.apecell.com/2007/09/28/id/11</link>
		<comments>http://blog.apecell.com/2007/09/28/id/11#comments</comments>
		<pubDate>Thu, 27 Sep 2007 15:00:00 +0000</pubDate>
		<dc:creator>design</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[Program]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zendframework]]></category>

		<guid isPermaLink="false">http://blog.apecell.com/1970/01/01/11</guid>
		<description><![CDATA[Zend_MailのSMTPによるメール送信で単一コネクションで複数のメールを送信する場合のマニュアルが間違えているので注意。確認したVersionと箇所は以下。
ZendFramework1.0.221.3. SMTP 接続による複数のメールの送信
「例 21.4. SMTP 雪像による複数のメールの送信」によると以下の様に書かれている。


require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
// メッセージを作成します...
require_once 'Zend/Mail/Transport/Smtp.php';
$tr = new Zend_Mail_Transport_Smtp('mail.example.com');
Zend_Mail::setDefaultTransport($tr);
$tr-&#62;connect();
for ($i = 0; $i &#38;lt; 5; $i++) {
$mail-&#62;send();
}
$tr-&#62;disconnect();


が、上記だとZend_Mail_Transport_Smtpにconnectメソッドが無いのでエラーになる。
代わりにZend_Mail_Protocol_Smtpにあるのでそっちでコネクションを張ってZend_Mail_Transport_SmtpのsetConnectionメソッドでセットしてやる。

&#60;?php
$connection = new Zend_Mail_Protocol_Smtp($host, $port);
$connection-&#62;connect();
$connection-&#62;helo();

$tr = new Zend_Mail_Transport_Smtp;
$tr-&#62;setConnection($connection);

// 以下ループ処理
$mail = new Zend_Mail();

上記方法で1コネクションで複数のメール送信が出来る。
Zend_Mail_Transport_Smtpのデストラクタでdisconnectメドッソが呼ばれて自動的に接続解除されるので通常は問題無い。しかしSMTP接続がネットワーク障害で切れてしまった場合、disconnectの前に呼ばれるSMTPコマンドのQUITで例外が投げられるがデストラクタの例外は拾えなくてFatal Errorになってしまうので注意。
]]></description>
			<content:encoded><![CDATA[<p>Zend_MailのSMTPによるメール送信で単一コネクションで複数のメールを送信する場合のマニュアルが間違えているので注意。確認したVersionと箇所は以下。</p>
<p>ZendFramework1.0.2<br /><a href="http://framework.zend.com/manual/ja/zend.mail.multiple-emails.html" target="_blank">21.3. SMTP 接続による複数のメールの送信</a></p>
<p>「例 21.4. SMTP 雪像による複数のメールの送信」によると以下の様に書かれている。</p>
<blockquote>
<pre name="code" class="php">
require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
// メッセージを作成します...
require_once 'Zend/Mail/Transport/Smtp.php';
$tr = new Zend_Mail_Transport_Smtp('mail.example.com');
Zend_Mail::setDefaultTransport($tr);
$tr-&gt;connect();
for ($i = 0; $i &amp;lt; 5; $i++) {
$mail-&gt;send();
}
$tr-&gt;disconnect();
</pre>
</blockquote>
<p>が、上記だとZend_Mail_Transport_Smtpにconnectメソッドが無いのでエラーになる。</p>
<p>代わりにZend_Mail_Protocol_Smtpにあるのでそっちでコネクションを張ってZend_Mail_Transport_SmtpのsetConnectionメソッドでセットしてやる。</p>
<pre name="code" class="php">
&lt;?php
$connection = new Zend_Mail_Protocol_Smtp($host, $port);
$connection-&gt;connect();
$connection-&gt;helo();

$tr = new Zend_Mail_Transport_Smtp;
$tr-&gt;setConnection($connection);

// 以下ループ処理
$mail = new Zend_Mail();
</pre>
<p>上記方法で1コネクションで複数のメール送信が出来る。</p>
<p>Zend_Mail_Transport_Smtpのデストラクタでdisconnectメドッソが呼ばれて自動的に接続解除されるので通常は問題無い。しかしSMTP接続がネットワーク障害で切れてしまった場合、disconnectの前に呼ばれるSMTPコマンドのQUITで例外が投げられるがデストラクタの例外は拾えなくてFatal Errorになってしまうので注意。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.apecell.com/2007/09/28/id/11/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
