public function testReport()
 {
     //  Arrange.
     $transport = new \Swift_SmtpTransport();
     $transport->setHost('mailtrap.io');
     $transport->setPort(2525);
     $transport->setUsername(getenv('MAILTRAP_USERNAME'));
     $transport->setPassword(getenv('MAILTRAP_PASSWORD'));
     $mailer = new Swift_Mailer($transport);
     $message = new Swift_Message();
     $message->addTo('*****@*****.**');
     $message->setFrom('*****@*****.**');
     $body = new Body(new VarCloner(), new CliDumper());
     $compiler = new Compiler(new CommonMarkConverter(), new CssToInlineStyles());
     $email = new Email($mailer, $message, $body, $compiler);
     $exception = new DomainException('Testing a domain exception');
     $extra = ['only' => 'testing12321'];
     // Act.
     $email->report($exception, $extra);
     // Assert.
     $message = $this->mailtrap->get('inboxes/' . getenv('MAILTRAP_INBOX') . '/messages')->json()[0];
     $this->assertSame('Exception: Testing a domain exception', $message['subject']);
     $this->assertContains('$email->report($exception, $extra);', $message['text_body']);
     $this->assertContains("exception 'DomainException' with message 'Testing a domain exception'", $message['text_body']);
     $this->assertContains('{main}', $message['text_body']);
     $this->assertContains('"only" => "testing12321"', $message['text_body']);
     $this->assertContains('_SERVER', $message['text_body']);
 }
Esempio n. 2
0
 /**
  * Changes mailer configuration on runtime
  *
  * @param MailerConfiguration $mailerConfiguration
  *
  * @return \Swift_Mailer
  */
 protected function createMailer(MailerConfiguration $mailerConfiguration)
 {
     $transport = new \Swift_SmtpTransport();
     $transport->setHost($mailerConfiguration->getHost());
     $transport->setPort($mailerConfiguration->getPort());
     $transport->setUsername($mailerConfiguration->getUser());
     $transport->setPassword($mailerConfiguration->getPass());
     return \Swift_Mailer::newInstance($transport);
 }
Esempio n. 3
0
 public function __construct(array $options = array())
 {
     $swiftTransort = new \Swift_SmtpTransport();
     $swiftTransort->setHost($options['smtp']);
     $swiftTransort->setPort($options['port']);
     if (isset($options['encryption'])) {
         $swiftTransort->setEncryption($options['encryption']);
     }
     if (isset($options['username'])) {
         $swiftTransort->setUsername($options['username']);
     }
     if (isset($options['password'])) {
         $swiftTransort->setPassword($options['password']);
     }
     if (isset($options['auth_mode'])) {
         $swiftTransort->setAuthMode($options['auth_mode']);
     }
     $this->_mailer = new \Swift_Mailer($swiftTransort);
 }
Esempio n. 4
0
 private function createSmtpTransport(array $config = null)
 {
     $transport = new \Swift_SmtpTransport();
     if (!$config) {
         return $transport;
     }
     if (isset($config['host'])) {
         $transport->setHost($config['host']);
     }
     if (isset($config['port'])) {
         $transport->setPort($config['port']);
     }
     if (isset($config['encryption'])) {
         $transport->setEncryption($config['encryption']);
     }
     if (isset($config['username'])) {
         $transport->setUsername($config['username']);
     }
     if (isset($config['password'])) {
         $transport->setPassword($config['password']);
     }
     return $transport;
 }
Esempio n. 5
0
 /**
  * @return \Swift_Mailer
  */
 protected function createMailer()
 {
     $transport = new \Swift_SmtpTransport($this->host);
     if ($this->port) {
         $transport->setPort($this->port);
     }
     if ($this->username) {
         $transport->setUsername($this->username);
     }
     if ($this->password) {
         $transport->setPassword($this->password);
     }
     if ($this->encryption) {
         $transport->setEncryption($this->encryption);
     }
     return \Swift_Mailer::newInstance($transport);
 }
Esempio n. 6
0
});
$app->get('/unsubscribe/{token}', function ($token) use($app) {
    $repo = $app['orm.em']->getRepository('MikeyMike\\RfcDigestor\\Entity\\Subscriber');
    if ($subscriber = $repo->findOneBy(['unsubscribeToken' => $token])) {
        $em = $app['orm.em'];
        $em->remove($subscriber);
        $em->flush();
        $app['session']->getFlashBag()->add('message', sprintf('You successfully unsubscribed!'));
    }
    return $app->redirect('/');
});
$app['swift'] = function ($app) {
    $conf = $app['config'];
    $transport = new Swift_SmtpTransport();
    $transport->setHost($conf->get('smtp.host'));
    $transport->setPort($conf->get('smtp.port'));
    $transport->setUsername($conf->get('smtp.username'));
    $transport->setPassword($conf->get('smtp.password'));
    $transport->setEncryption($conf->get('smtp.security'));
    $mailer = new Swift_Mailer($transport);
    $mailer->registerPLugin(new CssInlinerPlugin());
    return $mailer;
};
$app['rfc.builder'] = function ($app) {
    return new RfcBuilder($app['config']->get('storagePath'));
};
$app['rfc.service'] = function ($app) {
    return new RfcService($app['rfc.builder'], $app['config']->get('rfcUrl'));
};
$app['diff.service'] = function ($app) {
    return new DiffService();