当前位置: 首页>>代码示例>>PHP>>正文


PHP sfMailer::compose方法代码示例

本文整理汇总了PHP中sfMailer::compose方法的典型用法代码示例。如果您正苦于以下问题:PHP sfMailer::compose方法的具体用法?PHP sfMailer::compose怎么用?PHP sfMailer::compose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfMailer的用法示例。


在下文中一共展示了sfMailer::compose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sfMailer

    $mailer = new sfMailer($dispatcher, array('delivery_strategy' => 'single_address'));
    $t->fail('__construct() throws an InvalidArgumentException exception if the delivery_address option is not set with the spool single_address strategy');
} catch (InvalidArgumentException $e) {
    $t->pass('__construct() throws an InvalidArgumentException exception if the delivery_address option is not set with the spool single_address strategy');
}
$mailer = new sfMailer($dispatcher, array('delivery_strategy' => 'single_address', 'delivery_address' => 'foo@example.com'));
$t->is($mailer->getDeliveryAddress(), 'foo@example.com', '__construct() recognizes the single_address delivery strategy');
// logging
$mailer = new sfMailer($dispatcher, array('logging' => false));
$t->is($mailer->getLogger(), null, '__construct() disables logging if the logging option is set to false');
$mailer = new sfMailer($dispatcher, array('logging' => true));
$t->ok($mailer->getLogger() instanceof sfMailerMessageLoggerPlugin, '__construct() enables logging if the logging option is set to true');
// ->compose()
$t->diag('->compose()');
$mailer = new sfMailer($dispatcher, array('delivery_strategy' => 'none'));
$t->ok($mailer->compose() instanceof Swift_Message, '->compose() returns a Swift_Message instance');
$message = $mailer->compose('from@example.com', 'to@example.com', 'Subject', 'Body');
$t->is($message->getFrom(), array('from@example.com' => ''), '->compose() takes the from address as its first argument');
$t->is($message->getTo(), array('to@example.com' => ''), '->compose() takes the to address as its second argument');
$t->is($message->getSubject(), 'Subject', '->compose() takes the subject as its third argument');
$t->is($message->getBody(), 'Body', '->compose() takes the body as its fourth argument');
// ->composeAndSend()
$t->diag('->composeAndSend()');
$mailer = new sfMailer($dispatcher, array('logging' => true, 'delivery_strategy' => 'none'));
$mailer->composeAndSend('from@example.com', 'to@example.com', 'Subject', 'Body');
$t->is($mailer->getLogger()->countMessages(), 1, '->composeAndSend() composes and sends the message');
$messages = $mailer->getLogger()->getMessages();
$t->is($messages[0]->getFrom(), array('from@example.com' => ''), '->composeAndSend() takes the from address as its first argument');
$t->is($messages[0]->getTo(), array('to@example.com' => ''), '->composeAndSend() takes the to address as its second argument');
$t->is($messages[0]->getSubject(), 'Subject', '->composeAndSend() takes the subject as its third argument');
$t->is($messages[0]->getBody(), 'Body', '->composeAndSend() takes the body as its fourth argument');
开发者ID:hunde,项目名称:bsc,代码行数:31,代码来源:sfMailerTest.php

示例2: sendNotificationEmail

 static function sendNotificationEmail($name, sfMailer $mailer, aPollPoll $poll, aPollAnswer $answer)
 {
     if (!self::getSendNotification($name)) {
         return false;
     }
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     $from = self::isUserOrEmail(self::getNotificationEmailFrom($name), true);
     $to = self::isUserOrEmail(self::getNotificationEmailTo($name), true);
     if (is_null($to)) {
         throw new sfException('No destination email defined. Cannot send a notification.');
     }
     $form_name = aPollToolkit::getPollFormName($poll->getType());
     $arguments = array('poll' => $poll, 'poll_form' => new $form_name($answer->getFieldsAsArray()), 'answer' => $answer);
     $message = $mailer->compose($from, $to);
     //$message->setContentType("text/html");
     $message->setSubject(get_partial(self::getNotificationEmailTitlePartial($name), $arguments));
     $body = get_partial(self::getNotificationEmailBodyPartial($name), $arguments);
     $message->addPart(self::createPlainTextBody($body), 'text/plain');
     $message->addPart(self::createHtmlBody($poll->getType(), $body), 'text/html');
     $mailer->send($message);
     return true;
 }
开发者ID:rbolliger,项目名称:apostrophePollPlugin,代码行数:22,代码来源:BaseaPollToolkit.class.php


注:本文中的sfMailer::compose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。