|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Mailer\SwiftMailer; |
|
6
|
|
|
|
|
7
|
|
|
use Psr\EventDispatcher\EventDispatcherInterface; |
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Swift_Events_EventListener; |
|
10
|
|
|
use Swift_Mailer; |
|
11
|
|
|
use Swift_Transport; |
|
12
|
|
|
use Yiisoft\Mailer\Mailer as BaseMailer; |
|
13
|
|
|
use Yiisoft\Mailer\MessageBodyRenderer; |
|
|
|
|
|
|
14
|
|
|
use Yiisoft\Mailer\MessageFactoryInterface; |
|
15
|
|
|
use Yiisoft\Mailer\MessageInterface; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Mailer implements a mailer based on SwiftMailer. |
|
19
|
|
|
* |
|
20
|
|
|
* @see https://swiftmailer.symfony.com |
|
21
|
|
|
*/ |
|
22
|
|
|
final class Mailer extends BaseMailer |
|
23
|
|
|
{ |
|
24
|
|
|
private Swift_Mailer $swiftMailer; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param MessageFactoryInterface $messageFactory |
|
28
|
|
|
* @param MessageBodyRenderer $messageBodyRenderer |
|
29
|
|
|
* @param EventDispatcherInterface $eventDispatcher |
|
30
|
|
|
* @param Swift_Transport $transport |
|
31
|
3 |
|
* @param Swift_Events_EventListener[] $plugins |
|
32
|
|
|
*/ |
|
33
|
3 |
|
public function __construct( |
|
34
|
|
|
MessageFactoryInterface $messageFactory, |
|
35
|
|
|
MessageBodyRenderer $messageBodyRenderer, |
|
36
|
|
|
EventDispatcherInterface $eventDispatcher, |
|
37
|
|
|
Swift_Transport $transport, |
|
38
|
|
|
array $plugins = [] |
|
39
|
|
|
) { |
|
40
|
|
|
parent::__construct($messageFactory, $messageBodyRenderer, $eventDispatcher); |
|
41
|
|
|
$this->swiftMailer = new Swift_Mailer($transport); |
|
42
|
|
|
|
|
43
|
4 |
|
foreach ($plugins as $plugin) { |
|
44
|
|
|
$this->swiftMailer->registerPlugin($plugin); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
protected function sendMessage(MessageInterface $message): void |
|
49
|
|
|
{ |
|
50
|
4 |
|
/** @var Message $message */ |
|
51
|
4 |
|
$sent = $this->swiftMailer->send($message->getSwiftMessage()); |
|
52
|
4 |
|
|
|
53
|
|
|
if ($sent === 0) { |
|
54
|
1 |
|
throw new RuntimeException('Unable send message.'); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths