| 1234567891011121314151617181920212223242526272829 |
- <sect1 id="zend.mail.different-transports">
- <title>使用不同的Transport对象</title>
- <para>
- 有时你想想使用不同的连接来发送不同的邮件,你也可以不预先调用<code>setDefaultTransport()</code>方法,而直接将Transport对象传递给<code>send()</code>。被传递的transport对象会在实际的<code>send()</code>调用中替代缺省的transport:
- </para>
- <example id="zend.mail.different-transports.example-1">
- <title>使用不同的Transport对象</title>
- <programlisting role="php"><![CDATA[<?php
- require_once 'Zend/Mail.php';
- $mail = new Zend_Mail();
- // build message...
- require_once 'Zend/Mail/Transport/Smtp.php';
- $tr1 = new Zend_Mail_Transport_Smtp('server@example.com');
- $tr2 = new Zend_Mail_Transport_Smtp('other_server@example.com');
- $mail->send($tr1);
- $mail->send($tr2);
- $mail->send(); // use default again?>]]>
- </programlisting>
- </example>
- <note>
- <title>外加的transports</title>
- <para>
- 外加transport,需要实现<code>Zend_Mail_Transport_Interface</code>接口。
- </para>
- </note>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|