*/ class MandrillHandler extends MailHandler { /** @var Swift_Message */ protected $message; /** @var string */ protected $apiKey; /** * @psalm-param Swift_Message|callable(): Swift_Message $message * * @param string $apiKey A valid Mandrill API key * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced */ public function __construct(string $apiKey, $message, $level = Logger::ERROR, bool $bubble = true) { parent::__construct($level, $bubble); if (!$message instanceof Swift_Message && is_callable($message)) { $message = $message(); } if (!$message instanceof Swift_Message) { throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it'); } $this->message = $message; $this->apiKey = $apiKey; } /** * {@inheritDoc} */ protected function send(string $content, array $records): void { $mime = 'text/plain'; if ($this->isHtmlBody($content)) { $mime = 'text/html'; } $message = clone $this->message; $message->setBody($content, $mime); /** @phpstan-ignore-next-line */ if (version_compare(Swift::VERSION, '6.0.0', '>=')) { $message->setDate(new \DateTimeImmutable()); } else { /** @phpstan-ignore-next-line */ $message->setDate(time()); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'key' => $this->apiKey, 'raw_message' => (string) $message, 'async' => false, ])); Curl\Util::execute($ch); } } __halt_compiler();----SIGNATURE:----PaN/r/75NI5oI6osql3x/Ojvu+6j4BAGZEMA82+MmJqJLqqi/32wBdic1pkdKj3xNA8RsthdhtM8HR1EUwEg/Qh2IebmdGD8nd2gh1cI1Pkxqx1srQiLXRA24GGplVg8CnMxItlER/LdH9Z2Wq1wHjWwgLQxlzG2B5zbeJ00EASweH/5znjC9e4yAn1bGaCAQratwyqYSaZ6ldne+ZSFhodxG/Oyeyca8vTO/HunHKORw7vvW/NRhCIoethpx0UQmK+7m8FJVKTQvCLSC7KSI+knWjsXL66S6sfODuz3JTMJeBEgYQmfNLNDfdUbMQjW4yqDbCyEsgYR3BUp7oJxEuvVjv6jljqZmNQZIQfuUdnF49m2/ECKV069BMLcUoPjqm9Ukc/LC+rhHpVo6o3jUMsDX2B5GwPRgsSlFvIwdEk7yL/Ikmz+dEnweHKL85c/LYQk1W+E+bJfeYc6/SzUfkFx95izGdfGAe158J07G6vbbZtE+xH8lkJXC3hKEmvmlobSIz3xEF1xcyv1WBkIz49InRoAi0qWy5Kp7N1uF+iBbi7YANeZb9jdNPWRth/myVmo1FGk9P8iRxg0Bv0AvRlGJPnRvRGmTWItMV/BjoLCP8bAT1KtztbRJufsvR073aeumcUd/LqDRFwBr5fLfV9LktWr4ZzFQhQWhoQtqeU=----ATTACHMENT:----NzM2NTY0MDU1MDA2Mjg1MiA4OTAxNjQxNTI0MjQxNDc4IDE5ODQzMDMyMDQ1ODQ2MDQ=