-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #612 from PennyDreadfulMTG/reset-password
Flesh out password reset email behavior
- Loading branch information
Showing
5 changed files
with
208 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
// Use Brevo to send an email from us to a single recipient. Brevo supports multiple recipients, attachments, etc. but we don't need that yet. | ||
function sendEmail($to, $subj, $msg): bool | ||
{ | ||
global $CONFIG; | ||
|
||
$body = [ | ||
'sender' => ['name' => 'Gatherling', 'email' => 'no-reply@gatherling.com'], | ||
'to' => [['name' => $to, 'email' => $to]], | ||
'subject' => $subj, | ||
'htmlContent' => $msg, | ||
]; | ||
|
||
$ch = curl_init(); | ||
|
||
curl_setopt($ch, CURLOPT_URL, 'https://api.brevo.com/v3/smtp/email'); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); | ||
|
||
$headers = []; | ||
$headers[] = 'Accept: application/json'; | ||
$headers[] = 'Api-Key: '.$CONFIG['brevo_api_key']; | ||
$headers[] = 'Content-Type: application/json'; | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | ||
|
||
curl_exec($ch); | ||
if (curl_errno($ch)) { | ||
return false; | ||
} | ||
$response_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); | ||
if ($response_code >= 300) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters