本文整理汇总了PHP中sfMailer类的典型用法代码示例。如果您正苦于以下问题:PHP sfMailer类的具体用法?PHP sfMailer怎么用?PHP sfMailer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfMailer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enviarMail
public static function enviarMail($destinatario, $titulo, $mensaje)
{
$mailer = new sfMailer();
if ($mailer->composeAndSend($from, $destinatario, $titulo, $mensaje) > 0) {
return 'ok';
} else {
return 'No se pudo enviar el correo a ' . $destinatario;
}
}
示例2: enableMailer
/**
* Loads the Swift mailer
*/
public static function enableMailer()
{
if (!class_exists('Swift_Message')) {
Swift::registerAutoload();
sfMailer::initialize();
}
}
示例3: initializeMailer
protected function initializeMailer()
{
require_once sfConfig::get('sf_symfony_lib_dir') . '/vendor/swiftmailer/classes/Swift.php';
Swift::registerAutoload();
sfMailer::initialize();
$config = sfFactoryConfigHandler::getConfiguration($this->configuration->getConfigPaths('config/factories.yml'));
return new $config['mailer']['class']($this->dispatcher, $config['mailer']['param']);
}
示例4: array
}
$class = sfConfig::get('sf_factory_controller', 'sfFrontWebController');
$this->factories['controller'] = new $class($this);
$class = sfConfig::get('sf_factory_request', 'sfWebRequest');
$this->factories['request'] = new $class($this->dispatcher, array(), array(), sfConfig::get('sf_factory_request_parameters', array('logging' => '1', 'path_info_array' => 'SERVER', 'path_info_key' => 'PATH_INFO', 'relative_url_root' => NULL, 'formats' => array('txt' => 'text/plain', 'js' => array(0 => 'application/javascript', 1 => 'application/x-javascript', 2 => 'text/javascript'), 'css' => 'text/css', 'json' => array(0 => 'application/json', 1 => 'application/x-json'), 'xml' => array(0 => 'text/xml', 1 => 'application/xml', 2 => 'application/x-xml'), 'rdf' => 'application/rdf+xml', 'atom' => 'application/atom+xml'), 'no_script_name' => false)), sfConfig::get('sf_factory_request_attributes', array()));
$class = sfConfig::get('sf_factory_response', 'sfWebResponse');
$this->factories['response'] = new $class($this->dispatcher, sfConfig::get('sf_factory_response_parameters', array_merge(array('http_protocol' => isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null), array('logging' => '1', 'charset' => 'utf-8', 'send_http_headers' => false))));
if ($this->factories['request'] instanceof sfWebRequest && $this->factories['response'] instanceof sfWebResponse && 'HEAD' == $this->factories['request']->getMethod()) {
$this->factories['response']->setHeaderOnly(true);
}
$class = sfConfig::get('sf_factory_routing', 'sfPatternRouting');
$cache = null;
$this->factories['routing'] = new $class($this->dispatcher, $cache, array_merge(array('auto_shutdown' => false, 'context' => $this->factories['request']->getRequestContext()), sfConfig::get('sf_factory_routing_parameters', array('load_configuration' => true, 'suffix' => '', 'default_module' => 'default', 'default_action' => 'index', 'debug' => '1', 'logging' => '1', 'generate_shortest_url' => false, 'extra_parameters_as_query_string' => false, 'cache' => NULL))));
if ($parameters = $this->factories['routing']->parse($this->factories['request']->getPathInfo())) {
$this->factories['request']->addRequestParameters($parameters);
}
$class = sfConfig::get('sf_factory_storage', 'sfSessionTestStorage');
$this->factories['storage'] = new $class(array_merge(array('auto_shutdown' => false, 'session_id' => $this->getRequest()->getParameter('symfony')), sfConfig::get('sf_factory_storage_parameters', array('session_name' => 'symfony', 'session_path' => '/var/www/production/sfweb/www/cache/symfony-for-release/1.3.4/test/functional/fixtures/cache/frontend/test/test/sessions'))));
$class = sfConfig::get('sf_factory_user', 'myUser');
$this->factories['user'] = new $class($this->dispatcher, $this->factories['storage'], array_merge(array('auto_shutdown' => false, 'culture' => $this->factories['request']->getParameter('sf_culture')), sfConfig::get('sf_factory_user_parameters', array('timeout' => 1800, 'logging' => '1', 'use_flash' => true, 'default_culture' => 'en'))));
if (sfConfig::get('sf_cache')) {
$class = sfConfig::get('sf_factory_view_cache', 'sfFileCache');
$cache = new $class(sfConfig::get('sf_factory_view_cache_parameters', array('automatic_cleaning_factor' => 0, 'cache_dir' => '/var/www/production/sfweb/www/cache/symfony-for-release/1.3.4/test/functional/fixtures/cache/frontend/test/template', 'lifetime' => 86400, 'prefix' => '/var/www/production/sfweb/www/cache/symfony-for-release/1.3.4/test/functional/fixtures/apps/frontend/template')));
$this->factories['viewCacheManager'] = new sfViewCacheManager($this, $cache, array('cache_key_use_vary_headers' => true, 'cache_key_use_host_name' => true));
} else {
$this->factories['viewCacheManager'] = null;
}
require_once sfConfig::get('sf_symfony_lib_dir') . '/vendor/swiftmailer/classes/Swift.php';
Swift::registerAutoload();
sfMailer::initialize();
$this->setMailerConfiguration(array_merge(array('class' => sfConfig::get('sf_factory_mailer', 'sfMailer')), sfConfig::get('sf_factory_mailer_parameters', array('logging' => '1', 'charset' => 'utf-8', 'delivery_strategy' => 'realtime', 'transport' => array('class' => 'Swift_SmtpTransport', 'param' => array('host' => 'localhost', 'port' => 25, 'encryption' => NULL, 'username' => NULL, 'password' => NULL))))));
示例5: getMailer
/**
* Retrieves the mailer.
*
* @return sfMailer The current sfMailer implementation instance.
*/
public function getMailer()
{
if (!isset($this->factories['mailer'])) {
Swift::registerAutoload();
sfMailer::initialize();
$this->factories['mailer'] = new $this->mailerConfiguration['class']($this->dispatcher, $this->mailerConfiguration);
}
return $this->factories['mailer'];
}
示例6: sfMailer
$mailer = new sfMailer($dispatcher, array('logging' => true, 'delivery_strategy' => 'spool', 'spool_class' => 'TestSpool', 'spool_arguments' => array('TestMailMessage'), 'transport' => array('class' => 'TestMailerTransport')));
$transport = $mailer->getRealtimeTransport();
$spool = $mailer->getTransport()->getSpool();
$t->is($mailer->sendNextImmediately(), $mailer, '->sendNextImmediately() implements a fluid interface');
$mailer->composeAndSend('from@example.com', 'to@example.com', 'Subject', 'Body');
$t->is($spool->getQueuedCount(), 0, '->sendNextImmediately() bypasses the spool');
$t->is($transport->getSentCount(), 1, '->sendNextImmediately() bypasses the spool');
$transport->reset();
$spool->reset();
$mailer->composeAndSend('from@example.com', 'to@example.com', 'Subject', 'Body');
$t->is($spool->getQueuedCount(), 1, '->sendNextImmediately() bypasses the spool but only for the very next message');
$t->is($transport->getSentCount(), 0, '->sendNextImmediately() bypasses the spool but only for the very next message');
// ->getDeliveryAddress() ->setDeliveryAddress()
$t->diag('->getDeliveryAddress() ->setDeliveryAddress()');
$mailer = new sfMailer($dispatcher, array('delivery_strategy' => 'none'));
$mailer->setDeliveryAddress('foo@example.com');
$t->is($mailer->getDeliveryAddress(), 'foo@example.com', '->setDeliveryAddress() sets the delivery address for the single_address strategy');
// ->getLogger() ->setLogger()
$t->diag('->getLogger() ->setLogger()');
$mailer = new sfMailer($dispatcher, array('delivery_strategy' => 'none'));
$mailer->setLogger($logger = new sfMailerMessageLoggerPlugin($dispatcher));
$t->ok($mailer->getLogger() === $logger, '->setLogger() sets the mailer logger');
// ->getDeliveryStrategy()
$t->diag('->getDeliveryStrategy()');
$mailer = new sfMailer($dispatcher, array('delivery_strategy' => 'none'));
$t->is($mailer->getDeliveryStrategy(), 'none', '->getDeliveryStrategy() returns the delivery strategy');
// ->getRealtimeTransport() ->setRealtimeTransport()
$t->diag('->getRealtimeTransport() ->setRealtimeTransport()');
$mailer = new sfMailer($dispatcher, array('delivery_strategy' => 'none'));
$mailer->setRealtimeTransport($transport = new TestMailerTransport());
$t->ok($mailer->getRealtimeTransport() === $transport, '->setRealtimeTransport() sets the mailer transport');
示例7: 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;
}
示例8: __construct
public function __construct(sfEventDispatcher $dispatcher, $options)
{
// Load client based configuration
$cfg = EmailConfiguration::getCurrent();
// Update settings for the current client
$options["transport"]["param"]["host"] = $cfg['host'];
$options["transport"]["param"]["port"] = $cfg['port'];
$options["transport"]["param"]["username"] = $cfg['username'];
$options["transport"]["param"]["password"] = $cfg['password'];
parent::__construct($dispatcher, $options);
}