Conditions | 4 |
Paths | 4 |
Total Lines | 31 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function dispatch(MessageInterface $message) |
||
17 | { |
||
18 | // Get the dispatch and message data from the message. |
||
19 | $dispatchData = $message->getDispatchData(); |
||
20 | $messageData = $message->getMessageData(); |
||
21 | |||
22 | $mail = \Swift_Message::newInstance() |
||
23 | ->setSubject($messageData['title']) |
||
24 | ->setBody($messageData['body']); |
||
25 | |||
26 | $mail->setFrom($dispatchData['from']); |
||
27 | $mail->setTo($dispatchData['to']); |
||
28 | |||
29 | // Check if its a html email |
||
30 | if (!empty($messageData['html_email'])) { |
||
31 | $mail->setContentType('text/html'); |
||
32 | } |
||
33 | |||
34 | // Add any attachments |
||
35 | if (!empty($messageData['attachments'])) { |
||
36 | foreach ($messageData['attachments'] as $path => $filename) { |
||
37 | $mail->attach( |
||
38 | \Swift_Attachment::fromPath($path)->setFilename($filename) |
||
39 | ); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | $sent = $this->mailer->send($mail); |
||
44 | |||
45 | return !empty($sent); |
||
46 | } |
||
47 | } |