' . '' . '' . '
' . '' . '' . '
' . '🎮 ' . htmlspecialchars($siteName) . '' . '
' . '

Verify your account

' . '

Hey ' . htmlspecialchars($toName) . ',

' . '

Thanks for signing up! Click below to verify your email and activate your account.

' . '' . '

Or paste this into your browser:

' . '

' . htmlspecialchars($verifyUrl) . '

' . '

' . 'Link expires in 24 hours. Did not sign up? You can safely ignore this email.

' . '
' . '© ' . htmlspecialchars($siteName) . ' · ' . htmlspecialchars($siteUrl) . '' . '
'; return sendgridSend($toEmail, $toName, $subject, $text, $html); } function sendgridSend(string $toEmail, string $toName, string $subject, string $textBody, string $htmlBody = ''): bool { $apiKey = defined('SENDGRID_API_KEY') ? SENDGRID_API_KEY : ''; if (!$apiKey) { error_log('[TomTomGames mailer] SENDGRID_API_KEY not defined'); return false; } $payload = json_encode([ 'personalizations' => [['to' => [['email' => $toEmail, 'name' => $toName]]]], 'from' => [ 'email' => defined('SMTP_FROM') ? SMTP_FROM : 'noreply@tomtomgames.com', 'name' => defined('SMTP_FROM_NAME') ? SMTP_FROM_NAME : 'TomTomGames', ], 'subject' => $subject, 'content' => array_values(array_filter([ ['type' => 'text/plain', 'value' => $textBody], $htmlBody ? ['type' => 'text/html', 'value' => $htmlBody] : null, ])), ]); $ch = curl_init('https://api.sendgrid.com/v3/mail/send'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, 'Content-Type: application/json', ], CURLOPT_TIMEOUT => 20, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_FOLLOWLOCATION => true, ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlErr = curl_error($ch); curl_close($ch); if ($httpCode === 202) return true; error_log('[TomTomGames mailer] SendGrid HTTP ' . $httpCode . ' err=' . $curlErr . ' body=' . $response); return false; }