Laravel sendinblue emails
public static function sendSendInBlueMail()
{
$html = view('emails.template', [
'name' => 'User Name'
]);
$fields = [
'to' => [
[
"email" => '[email protected]',
"name" => 'User Name'
]
],
"sender" => [
"name" => 'Website Name',
"email" => '[email protected]'
],
"subject" => 'Sendinblue Email',
"cc" => [
[
"email" => '[email protected]',
"name" => 'User Name'
]
],
"htmlContent" => "<html><head></head>" . $html . "</html>"
];
$fields = json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.sendinblue.com/v3/smtp/email');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'accept: application/json',
'api-key:' . env("SENDINBLUEAPIKEY") . '', 'content-type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
return $response;
}
Email blade template
<body style="padding:0px;margin:0px;font-family: sans-serif;">
<h1>{{$name}}</h1>
</body>
click for more Laravel codes read about sendinblue api