protected function onSuccess() { /** @var Emails $mailLocal */ $mailLocal = $this->em->getRepository('BuddySystemMembersBundle:Emails')->findOneBy(array("key" => "welcome_local", "section" => $this->section)); $mailLocal = $this->replace_keys($mailLocal, $this->user); $message = \Swift_Message::newInstance()->setSubject($mailLocal->getSubject())->setFrom($this->section->getEmail())->setTo($this->user->getEmail())->setBody($mailLocal->getBody(), 'text/html'); $this->mailer->send($message); if ($this->section->isMailing()) { $buddycoordinators = $this->em->getRepository('BuddySystemUserBundle:User')->findBCBysection($this->section); /** @var User $buddycoordinator */ foreach ($buddycoordinators as $buddycoordinator) { $message = \Swift_Message::newInstance()->setSubject($this->translator->trans('email.mailing.subject', array("%type%" => "mentor")))->setFrom($this->section->getEmail())->setTo($buddycoordinator->getEmail())->setBody($this->translator->trans('email.mailing.body', array("%buddy_url%" => "http://" . $this->section->getSubdomain() . ".buddysystem.eu", "%type%" => "mentor")), 'text/html'); $this->mailer->send($message); } } }