本文整理汇总了PHP中Swift_Mailer::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Mailer::__construct方法的具体用法?PHP Swift_Mailer::__construct怎么用?PHP Swift_Mailer::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_Mailer
的用法示例。
在下文中一共展示了Swift_Mailer::__construct方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Swift_Transport $transport the transport method to use
* @param array $options sets the class properties passed in as and array
*/
public function __construct(Swift_Transport $transport, $options)
{
foreach ($options as $key => $option) {
$this->{$key} = $option;
}
parent::__construct($transport);
}
示例2: __construct
public function __construct(Swift_Transport $transport = null)
{
if (!$transport) {
$transport = Swift_MailTransport::newInstance();
// set transport from config (see method send)
$this->wa_set_transport = true;
}
parent::__construct($transport);
}
示例3: __construct
/**
*
* @param \Swift_Transport $transport
*/
public function __construct(\Zend_Config $webconfig)
{
$this->setWebconfig($webconfig);
if (null === $transport) {
$transport = $this->createTransport();
}
parent::__construct($transport);
\Swift_Preferences::getInstance()->setCharset('iso-8859-1');
}
示例4: __construct
/**
* @param Swift_Transport $transport
* @param array|null $headers
*/
public function __construct(Swift_Transport $transport, array $headers = null)
{
if (null === $headers) {
$headers = [];
}
$this->_headers = $headers;
CM_Mail_Message::register();
parent::__construct($transport);
}
示例5: __construct
public function __construct()
{
$this->registry = Registry::getInstance();
$this->mailerConfig = $this->registry->config->getMailer();
$this->message = \Swift_Message::newInstance();
echo $this->mailerConfig->getSender() . PHP_EOL;
$this->message->setFrom($this->mailerConfig->getSender());
$this->transport = \Swift_SmtpTransport::newInstance($this->mailerConfig->getHost(), $this->mailerConfig->getPort(), 'ssl')->setUsername($this->mailerConfig->getUser())->setPassword($this->mailerConfig->getPass());
parent::__construct($this->transport);
}
示例6: __construct
/**
* Constructor
*
* @param \Swift_Mailer $baseMailer
* @param ContainerInterface $container
*/
public function __construct(\Swift_Mailer $baseMailer, ContainerInterface $container)
{
$this->baseMailer = $baseMailer;
$this->container = $container;
$transport = $this->baseMailer->getTransport();
if ($transport instanceof \Swift_Transport_SpoolTransport) {
$transport = $this->findRealTransport();
if (!$transport) {
$transport = \Swift_NullTransport::newInstance();
}
}
parent::__construct($transport);
}
示例7: __construct
public function __construct($config)
{
if (isset($config['spool_dir'])) {
if (!file_exists($config['spool_dir'])) {
mkdir($config['spool_dir']);
}
$spooler = new \Swift_FileSpool($config['spool_dir']);
$spool_event_dispatcher = new \Swift_Events_SimpleEventDispatcher();
$this->spool_transport = new \Swift_Transport_SpoolTransport($spool_event_dispatcher, $spooler);
}
$this->smtp_transport = \Swift_SmtpTransport::newInstance($config['host'], $config['port'])->setUsername($config['username'])->setPassword($config['password']);
parent::__construct($this->spool_transport ? $this->spool_transport : $this->smtp_transport);
}
示例8: __construct
/**
* When constructing, also initializes the Swift_Transport like configured
*
* @param Swift_Transport optionally pass a transport to the constructor. By default the configured transport from $TYPO3_CONF_VARS is used
* @throws t3lib_exception
*/
public function __construct(Swift_Transport $transport = NULL)
{
if ($transport !== NULL) {
$this->transport = $transport;
} else {
try {
$this->initializeTransport();
} catch (Exception $e) {
throw new t3lib_exception($e->getMessage(), 1291068569);
}
}
parent::__construct($this->transport);
}
示例9: __construct
/**
* When constructing, also initializes the \Swift_Transport like configured
*
* @param null|\Swift_Transport $transport optionally pass a transport to the constructor.
* @throws \TYPO3\CMS\Core\Exception
*/
public function __construct(\Swift_Transport $transport = NULL)
{
if ($transport !== NULL) {
$this->transport = $transport;
} else {
if (empty($this->mailSettings)) {
$this->injectMailSettings();
}
try {
$this->initializeTransport();
} catch (\Exception $e) {
throw new \TYPO3\CMS\Core\Exception($e->getMessage(), 1291068569);
}
}
parent::__construct($this->transport);
}
示例10: __construct
/**
* Constructor
*
* @param \Swift_Mailer $baseMailer
* @param ContainerInterface $container
*/
public function __construct(\Swift_Mailer $baseMailer, ContainerInterface $container, ImapEmailGoogleOauth2Manager $imapEmailGoogleOauth2Manager)
{
$this->baseMailer = $baseMailer;
$this->container = $container;
$this->imapEmailGoogleOauth2Manager = $imapEmailGoogleOauth2Manager;
$transport = $this->baseMailer->getTransport();
if ($transport instanceof \Swift_Transport_SpoolTransport) {
$transport = $this->findRealTransport();
if (!$transport) {
$transport = \Swift_NullTransport::newInstance();
}
}
if ($transport instanceof \Swift_Transport_EsmtpTransport) {
$this->addXOAuth2Authenticator($transport);
}
parent::__construct($transport);
}
示例11: __construct
public function __construct(\Swift_Transport_EsmtpTransport $transport, ConfigManager $config, ContainerInterface $container)
{
$mandrillApiKey = $config->get('atwix_mandrill.api_key');
$mandrillApiUsername = $config->get('atwix_mandrill.api_username');
if ($config->get('atwix_mandrill.enable_mandrill_integration') && !empty($mandrillApiKey) && !empty($mandrillApiUsername)) {
$handlers = $transport->getExtensionHandlers();
/** @var \Swift_Transport_Esmtp_AuthHandler $handler */
$handler = reset($handlers);
$transport->setHost($config->get('atwix_mandrill.smtp_host'));
$transport->setPort($config->get('atwix_mandrill.smtp_port'));
$handler->setPassword($mandrillApiKey);
$handler->setUsername($mandrillApiUsername);
\Swift_Mailer::__construct($transport);
} else {
$mailer = $container->get('mailer');
parent::__construct($mailer, $container);
}
}
示例12: __construct
/**
* Constructor.
*
* Available options:
*
* * charset: The default charset to use for messages
* * logging: Whether to enable logging or not
* * delivery_strategy: The delivery strategy to use
* * spool_class: The spool class (for the spool strategy)
* * spool_arguments: The arguments to pass to the spool constructor
* * delivery_address: The email address to use for the single_address strategy
* * transport: The main transport configuration
* * * class: The main transport class
* * * param: The main transport parameters
*
* @param sfEventDispatcher $dispatcher An event dispatcher instance
* @param array $options An array of options
*/
public function __construct(sfEventDispatcher $dispatcher, $options)
{
// options
$options = array_merge(array('charset' => 'UTF-8', 'logging' => false, 'delivery_strategy' => 'realtime', 'transport' => array('class' => 'Swift_MailTransport', 'param' => array())), $options);
$constantName = 'sfMailer::' . strtoupper($options['delivery_strategy']);
$this->strategy = defined($constantName) ? constant($constantName) : false;
if (!$this->strategy) {
throw new InvalidArgumentException(sprintf('Unknown mail delivery strategy "%s" (should be one of realtime, spool, single_address, or none)', $options['delivery_strategy']));
}
// transport
$class = $options['transport']['class'];
$transport = new $class();
if (isset($options['transport']['param'])) {
foreach ($options['transport']['param'] as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($transport, $method)) {
$transport->{$method}($value);
} elseif (method_exists($transport, 'getExtensionHandlers')) {
foreach ($transport->getExtensionHandlers() as $handler) {
if (in_array(strtolower($method), array_map('strtolower', (array) $handler->exposeMixinMethods()))) {
$transport->{$method}($value);
}
}
}
}
}
$this->realtimeTransport = $transport;
if (sfMailer::SPOOL == $this->strategy) {
if (!isset($options['spool_class'])) {
throw new InvalidArgumentException('For the spool mail delivery strategy, you must also define a spool_class option');
}
$arguments = isset($options['spool_arguments']) ? $options['spool_arguments'] : array();
if ($arguments) {
$r = new ReflectionClass($options['spool_class']);
$this->spool = $r->newInstanceArgs($arguments);
} else {
$this->spool = new $options['spool_class']();
}
$transport = new Swift_SpoolTransport($this->spool);
} elseif (sfMailer::SINGLE_ADDRESS == $this->strategy) {
if (!isset($options['delivery_address'])) {
throw new InvalidArgumentException('For the single_address mail delivery strategy, you must also define a delivery_address option');
}
$this->address = $options['delivery_address'];
$transport->registerPlugin($this->redirectingPlugin = new Swift_Plugins_RedirectingPlugin($this->address));
}
parent::__construct($transport);
// logger
if ($options['logging']) {
$this->logger = new sfMailerMessageLoggerPlugin($dispatcher);
$transport->registerPlugin($this->logger);
}
if (sfMailer::NONE == $this->strategy) {
// must be registered after logging
$transport->registerPlugin(new Swift_Plugins_BlackholePlugin());
}
// preferences
Swift_Preferences::getInstance()->setCharset($options['charset']);
$dispatcher->notify(new sfEvent($this, 'mailer.configure'));
}