mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-23 02:56:02 +02:00
Much faster email sending with the new Message Broker
This commit is contained in:
parent
23d50a0b0c
commit
43e7b3250d
7 changed files with 286 additions and 174 deletions
|
@ -60,6 +60,32 @@ class Mail
|
|||
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
return false;
|
||||
}
|
||||
} else if (envi('MAIL_DRIVER') == 'msg') {
|
||||
$url = 'http://127.0.0.1:8250';
|
||||
$data = ['type' => 'sendmail', 'mailer' => 'phpmailer', 'toEmail' => $to['email'], 'subject' => $subject, 'body' => $body];
|
||||
|
||||
$options = [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => json_encode($data),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen(json_encode($data))
|
||||
],
|
||||
];
|
||||
|
||||
$curl = curl_init($url);
|
||||
curl_setopt_array($curl, $options);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if ($response === false) {
|
||||
throw new Exception(curl_error($curl), curl_errno($curl));
|
||||
}
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue