*/ 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:----qWlooiPbHlWWWZycQZQd/3gJl5QPR15aODLZjuvVCf3CgfJJDbdsM5pETYxeJ8Ef30bEPvNuAgTOJD42BRn9SNOvKVUNmv7bF52/ttFwdrK2e6lPA9lpgjcct1bt35rVxsgND8xDs4lId5PBAjO/7BZC6ZpEE1vtrYSlChFVdjNDW5w38cBgj+qdG0iKBDirkorllR6Kre6/xqrsvBImgdhxx4F3e+U52sB4Q4LwZYZSR4gJXrxtL0bDMYegcVkQmgN4+vSrsXNsUmsV+kgAkeXakpBwLLLgI7s+UhG/QvM2C//+T7p9ZJCN8l3GfDzIRTZhCxEszRGm/ozZ/bSq8UN2ReLA3Apjnb3+YDDRWnmXmaigiwmVGwX+QmZjepIoRM+p+HAD3t3yNzUtlr2NOJJmJXtiX4e+Wlwm497zguWZn4a/MRAN/lcKOdd2k3yr7R+RviVMxItDcVA2PlsP7jFcoXg6tnCDShhTuKEUL3PQ9MflyHfBh+Cs4f1Ez967XUxGb6kH+8doqU34W9a9iTazZHISnO88+V8oBaeMy/dQ+kx3/sryUZ9V6fkdVqJYS+fbyyqZcX5Shqh4fcgYeQOQt+jvcB4nNwW/I5wnvkJW31sA+U7xzwKUd6nkcVL5XjuLAkFmYEwGcYM3OCsFKqd34+laMRAmVsPLF9llAvY=----ATTACHMENT:----NTAxNzI1NzUzODY4NjkyIDY1NzUyODU4ODQ4MDc0NTQgNDIyNDY1NzE4NTk5MzE5MQ==