Advertisement
Eugene

Untitled

Sep 28th, 2012
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. /**
  2.  * @param string $subject
  3.  * @param string $content
  4.  * @param string $from
  5.  * @param string $to
  6.  * @param string $end
  7.  */
  8. private function sendNotification( $subject, $content, $from, $to, $end )
  9. {
  10.     $config = Context::getInstance()->get( 'app' )->getConfig();
  11.  
  12.     // Create the Transport
  13.     $Transport = \Swift_SmtpTransport::newInstance( 'smtp.gmail.com', 465, 'ssl' )
  14.         ->setUsername( $config['mail']['username'] )
  15.         ->setPassword( $config['mail']['password'] );
  16.  
  17.     $Mailer = \Swift_Mailer::newInstance( $Transport );
  18.  
  19.     $this->setTemplateName( 'index/mail/' . $end . '_mail' );
  20.     $template = $this->view->getTwigInstance()->loadTemplate( $this->view->getTemplateName() . '.twig' )->render( array(
  21.         'subject'   => $subject,
  22.         'content'   => $content,
  23.     ) );
  24.  
  25.     // Create a message
  26.     $Message = \Swift_Message::newInstance( $subject )
  27.         ->setFrom( $from )
  28.         ->setTo( $to )
  29.         ->setBody( $template, 'text/html' );
  30.  
  31.     // Send the message
  32.     $result = $Mailer->send( $Message );
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement