*/ 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:----Qis+zgVGq0dalMCcJh4L5FpzIZXoPWXCTgkjnzmDOCHgVz7EDL8Pvu6pE0bR7b7GYcPAyPndVmFSfWKDR0nV3LWYeMsGvHOMWmuWtKakS0fClk9k9CzrOJlJW/nIu2pi57RWGIJvpnfnnmbmVkPbVEH52+hvfaPGlffWUrzN3AZv+DoIYc21+a7FHgZn7iPbIhCTDWC2Ez8xKJKf29JSYQkgy7S3i+T13z0g3EEhPWl9sHW9+nmABOZS19+vLhdnLwoHI/oHSe7iaqaBj4gcpPhPIJf4CZkldI2o12/lZZBPdojg35xRO0QgcVM4cNFkj2s/kmcSfP5S3gleElSS6R3kyk88aKwXRJdmj6vQhE++xi5+paT/N1cv9N5eAURUm414Emw2+MxpdtIX8YFP4ufqSTfL6rTNx/jIe82hmSdbuBbiM0BkGAHpgSb4SJC36ewRXXu8I9re/IFygvPGDICmVTeFIII80iwQBCzWInFoeVWgPQs5bYNkD59jdfM4wnwaX+BVpRMmB/Olw/cpiWDewvV1gqpCKcnSKLHu7xwEhVi24UJ3G5vnAh764yX/tXtoMvcPiYD2gF8MKyrfSPlL8U8JE1mj4rmexe/gBAxlgxk015NTxS8ne+OgA1DXYwHglXm1BCxNCwl5DrB/wOdmfhqc7BMOSd70xDZFxSs=----ATTACHMENT:----MjA0MDYwNTcwOTQxODcwMCA1MzgyNjAyNzIxNDg2MTc3IDQyOTEzNjU1MzMyOTI0OQ==