Advertisement
Guest User

Untitled

a guest
Jan 10th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. class SomeCommand {
  2. /**
  3.  * config:
  4.  *
  5.  * swiftmailer:
  6.  *   transport:  smtp
  7.  *   encryption: ssl
  8.  *   auth_mode:  login
  9.  *   host:       smtp.example.com
  10.  *   username:   your_username
  11.  *   password:   your_password
  12. */
  13.     public function execute(){
  14.         $container = $this->getContainer();
  15.  
  16.         $mailer = $container->get('mailer'); // Swift_Mailer with smtp transport
  17.         $queue = $container->get('mail-queue');
  18.  
  19.         while($mailMessage = $queue->get()){
  20.             try{
  21.                 $mailer->send($mailMessage);
  22.             } catch(\Exception $e){
  23.                 // some catch logic
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement