*/ class SendGridHandler extends MailHandler { /** * The SendGrid API User * @var string */ protected $apiUser; /** * The SendGrid API Key * @var string */ protected $apiKey; /** * The email addresses to which the message will be sent * @var string */ protected $from; /** * The email addresses to which the message will be sent * @var string[] */ protected $to; /** * The subject of the email * @var string */ protected $subject; /** * @param string $apiUser The SendGrid API User * @param string $apiKey The SendGrid API Key * @param string $from The sender of the email * @param string|string[] $to The recipients of the email * @param string $subject The subject of the mail */ public function __construct( string $apiUser, string $apiKey, string $from, $to, string $subject, $level = Logger::ERROR, bool $bubble = true, ) { if (!extension_loaded('curl')) { throw new MissingExtensionException('The curl extension is needed to use the SendGridHandler'); } parent::__construct($level, $bubble); $this->apiUser = $apiUser; $this->apiKey = $apiKey; $this->from = $from; $this->to = (array) $to; $this->subject = $subject; } /** * {@inheritDoc} */ protected function send(string $content, array $records): void { $message = []; $message['api_user'] = $this->apiUser; $message['api_key'] = $this->apiKey; $message['from'] = $this->from; foreach ($this->to as $recipient) { $message['to[]'] = $recipient; } $message['subject'] = $this->subject; $message['date'] = date('r'); if ($this->isHtmlBody($content)) { $message['html'] = $content; } else { $message['text'] = $content; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.sendgrid.com/api/mail.send.json'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($message)); Curl\Util::execute($ch, 2); } } __halt_compiler();----SIGNATURE:----kDuYH6C/DmzycqqEt6uPzjwRzazIQ2HwT+SD+10bvF70VxDluh+vv2yfaRG9pjPf5uRD/6Q7O1bvv1AhwFjt4Cy4LDK4K/V4dxXcFzpoDXLWYi/5ICO81SFbAY1Ho/UFaNwYWu5i3rcK6v6mXiitM0F5cXcXRqs0C0veroj/uvibP7S2rGpXQxRTdVs0aTHjLiszUT4KbqykFYJk1ygRUOOzOT5bHvN0YAwVQyhGyKPmCCwMd3Vz+GC5QA7D9ypP8q7oLcU+2QOWSefHEh3D3Hz8ywhXoHRzoynh+jhy/6ryj8+saORq0rDbnlpgEx+hDNtA+2OC9eG55xxuW7j6UyQwmukvbA6dRWdoCuMT5+6+SseJMzrhJG8r0eY4tw7D+Ctuxxuw+EtA/WMvsahEkH3abkkzZEgt+7NiwKn60/ZwqhxmyzGid89wMLSE3qOhkwUmq0/W0HTNxdnnKgV9hs0Qky5CGgs0JOEkhaUnaU3TpUck4hUtXq6FpVIVmSW7QHPE6xQru76zFNiXCGouna78ckhuK/EiCXgD6ZL1fCqtMpIbBmGF/CuJyHZxO0EPqIBtV8+bO0d0Z50mkRtpzqoqoho42s1JJ/Sd4lq17Sxfp+mSHVtrGusU+qBo4xiZPXezxnNaxCxmsdYsSSIcTv3Y7WEj1/AZ5/o9aLBbBhs=----ATTACHMENT:----MzUyODE5MDkxNzI3MjI4MyA5MjI4MzQ1NTE4ODE0NTI1IDcyNDY4MTUxMDY5NzU2NDQ=