Beispiel #1
0
 /**
  * @expectedException \Oro\Bundle\EmailBundle\Exception\NotSupportedException
  */
 public function testRegisterPlugin()
 {
     $transport = $this->getMock('\\Swift_Transport');
     $this->baseMailer->expects($this->once())->method('getTransport')->will($this->returnValue($transport));
     $mailer = new DirectMailer($this->baseMailer, $this->container);
     $plugin = $this->getMock('\\Swift_Events_EventListener');
     $mailer->registerPlugin($plugin);
 }
Beispiel #2
0
 /**
  * Process send email message. In case exist custom smtp host/port use it
  *
  * @param \Swift_Message  $message
  * @param UserEmailOrigin $emailOrigin
  * @throws \Swift_SwiftException
  */
 public function processSend($message, $emailOrigin)
 {
     if ($emailOrigin instanceof UserEmailOrigin) {
         /* Modify transport smtp settings */
         if ($emailOrigin->isSmtpConfigured()) {
             $this->mailer->prepareSmtpTransport($emailOrigin);
         }
     }
     if (!$this->mailer->send($message)) {
         throw new \Swift_SwiftException('An email was not delivered.');
     }
 }
 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);
     }
 }