<?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>へっぽこ開発室 &#187; Zend_Mail</title>
	<atom:link href="http://wp.foliz.net/archives/tag/zend_mail/feed" rel="self" type="application/rss+xml" />
	<link>http://wp.foliz.net</link>
	<description>webプログラム　php,Smarty,Zend Framework,ajax,pearネタなど～</description>
	<lastBuildDate>Sat, 21 Jan 2012 06:32:52 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Zend_Mailで複数メール送信</title>
		<link>http://wp.foliz.net/archives/110</link>
		<comments>http://wp.foliz.net/archives/110#comments</comments>
		<pubDate>Fri, 31 Oct 2008 13:45:12 +0000</pubDate>
		<dc:creator>Fou</dc:creator>
				<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[Zend_Mail]]></category>

		<guid isPermaLink="false">http://wp.foliz.net/?p=110</guid>
		<description><![CDATA[複数箇所にメールを送信するとき、そのままZend_Mailで送信するとけっこう時間がかかる。 どうやらソケットをいちいちつないだりしてるかららしい。 $mail = new Zend_Mail&#40;$mailChar [...]]]></description>
			<content:encoded><![CDATA[<p>複数箇所にメールを送信するとき、そのままZend_Mailで送信するとけっこう時間がかかる。<br />
どうやらソケットをいちいちつないだりしてるかららしい。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Mail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mailCharset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addTo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mailaddress@xxxx.xx'</span><span style="color: #009900;">&#41;</span>
     <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFrom</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mailaddress@xxxx.xx'</span><span style="color: #009900;">&#41;</span>
     <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSubject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span>
     <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBodyText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>うちのサーバーで実行したら140秒かかった。</p>
<p>そこでトランスポートという機能を使う。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$transport</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Mail_Transport_Smtp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Mail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mailCharset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addTo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mailaddress@xxxx.xx'</span><span style="color: #009900;">&#41;</span>
     <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFrom</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mailaddress@xxxx.xx'</span><span style="color: #009900;">&#41;</span>
     <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSubject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span>
     <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBodyText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$transport</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>これで5秒になった。</p>
<p>実際に稼動プログラムに組み込んだけどあまりスピードがあがってない。。<br />
きっとまだ調整するところがあるんだろうな。</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.foliz.net/archives/110/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Mail+Smarty でメール送信</title>
		<link>http://wp.foliz.net/archives/76</link>
		<comments>http://wp.foliz.net/archives/76#comments</comments>
		<pubDate>Mon, 09 Jun 2008 13:35:19 +0000</pubDate>
		<dc:creator>Fou</dc:creator>
				<category><![CDATA[Smarty]]></category>
		<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[Zend_Mail]]></category>

		<guid isPermaLink="false">http://wp.foliz.net/archives/76</guid>
		<description><![CDATA[Zend Frameworkを使ったアプリケーションでSmartyテンプレートを使ったメール送信プログラム よく使いそうなのでメモメモ。。 ざっと簡単に書くとこんな感じ。 $smarty = new Smarty&#40 [...]]]></description>
			<content:encoded><![CDATA[<p>Zend Frameworkを使ったアプリケーションでSmartyテンプレートを使ったメール送信プログラム<br />
よく使いそうなのでメモメモ。。</p>
<p><span id="more-76"></span></p>
<p>ざっと簡単に書くとこんな感じ。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$smarty</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Smarty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template_dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'テンプレートフォルダのパス'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">compile_dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'テンプレート一時フォルダのパス'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assign</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>　<span style="color: #666666; font-style: italic;">//メールテンプレートにassignする</span>
&nbsp;
<span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'メールタイトル'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>body<span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'テンプレートファイル'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>fromEmail<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'送り主アドレス'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>fromName<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'送り主名'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>toEmail<span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'送信先アドレス'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>toName<span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'送信先名'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mb_convert_variables</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ISO-2022-JP'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'EUC-JP'</span><span style="color: #339933;">,</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>fromName<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'=?iso-2022-jp?B?'</span><span style="color: #339933;">.</span><span style="color: #990000;">base64_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>fromName<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?='</span><span style="color: #339933;">;</span>
&nbsp;
try<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$Mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Mail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ISO-2022-JP'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//送信用</span>
    <span style="color: #000088;">$Mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFrom</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>fromEmail<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>fromName<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
           <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addTo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>toEmail<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>toName<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
           <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSubject</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
           <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBodyText</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$send</span><span style="color: #009900;">&#91;</span>body<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
           <span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//エラー処理</span>
catch <span style="color: #009900;">&#40;</span>Zend_Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://wp.foliz.net/archives/76/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Mail でシンプルなメール送信</title>
		<link>http://wp.foliz.net/archives/69</link>
		<comments>http://wp.foliz.net/archives/69#comments</comments>
		<pubDate>Tue, 22 Jan 2008 07:56:37 +0000</pubDate>
		<dc:creator>Fou</dc:creator>
				<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[Zend_Mail]]></category>

		<guid isPermaLink="false">http://wp.foliz.net/archives/69</guid>
		<description><![CDATA[Zend_MailでもZend_Dbと同様、流れるようなインターフェイス形式でコールすることもできます。 「流れるようなインターフェイス」とは、 各メソッドの返り値が呼び出し元オブジェクト自身への参照となり、 その返り値 [...]]]></description>
			<content:encoded><![CDATA[<p>Zend_MailでもZend_Dbと同様、流れるようなインターフェイス形式でコールすることもできます。<br />
<span id="more-69"></span><br />
 「流れるようなインターフェイス」とは、 各メソッドの返り値が呼び出し元オブジェクト自身への参照となり、 その返り値からすぐに別のメソッドをコールできる形式のことを表します。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #339933;">&lt;</span> ?php
<span style="color: #000088;">$mailCharset</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ISO-2022-JP'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$crrCharset</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'EUC-JP'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Mail.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Mail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mailCharset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBodyText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'This is the text of the mail.'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFrom</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'somebody@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Some Sender'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addTo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'somebody_else@example.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Some Recipient'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSubject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TestSubject'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>ただしこのまま使っても日本語は化けます。<br />
Zend_mailは日本語バグ？があるようでちょっと癖があるのでちゃんと使えるようにするまでけっこう手間がかかったりします＾＾；</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.foliz.net/archives/69/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

