你好!在这篇文章中,我将与您分享一些小代码,如何发送 Laravel Sendinblue 电子邮件。我们将使用 sendinblue 提供的 CURL 选项发送电子邮件。
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 ; }
电子邮件刀片模板
<body style= "padding:0px;margin:0px;font-family: sans-serif;" > <h1> </h1> </body>
在此处获取 Sendinblue API
请喜欢分享并给予积极的反馈,以激励我写更多。
更多教程请访问我的网站。
谢谢:)
快乐编码:)
原文: https://dev.to/readymadecode/laravel-sendinblue-emails-1j41