/** * {@inheritdoc} */ public function send(array $recipients, $senderAddress, $senderName, RenderedEmail $renderedEmail, EmailInterface $email, array $data) { $message = \Swift_Message::newInstance()->setSubject($renderedEmail->getSubject())->setFrom([$senderAddress => $senderName])->setTo($recipients); $message->setBody($renderedEmail->getBody(), 'text/html'); $emailSendEvent = new EmailSendEvent($message, $email, $data, $recipients); $this->dispatcher->dispatch(SyliusMailerEvents::EMAIL_PRE_SEND, $emailSendEvent); $this->mailer->send($message); $this->dispatcher->dispatch(SyliusMailerEvents::EMAIL_POST_SEND, $emailSendEvent); }
function it_sends_an_email($mailer, EventDispatcherInterface $dispatcher, RenderedEmail $renderedEmail, EmailInterface $email) { $this->setEventDispatcher($dispatcher); $renderedEmail->getSubject()->shouldBeCalled()->willReturn('subject'); $renderedEmail->getBody()->shouldBeCalled()->willReturn('body'); $dispatcher->dispatch(SyliusMailerEvents::EMAIL_PRE_SEND, Argument::type(EmailSendEvent::class))->shouldBeCalled(); $mailer->send(Argument::type('\\Swift_Message'))->shouldBeCalled(); $dispatcher->dispatch(SyliusMailerEvents::EMAIL_POST_SEND, Argument::type(EmailSendEvent::class))->shouldBeCalled(); $this->send(['*****@*****.**'], '*****@*****.**', 'arnaud', $renderedEmail, $email, []); }