发布于 2015-10-07 09:57:46 | 92 次阅读 | 评论: 0 | 来源: 网络整理

25.4. 使用不同的Transport对象

有时你想想使用不同的连接来发送不同的邮件,你也可以不预先调用setDefaultTransport()方法,而直接将Transport对象传递给send()。被传递的transport对象会在实际的send()调用中替代缺省的transport:

例 25.6. 使用不同的Transport对象

<?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?>
       

[注意] 外加的transports

外加transport,需要实现Zend_Mail_Transport_Interface接口。

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务