getVerificationEmailTemplate($verificationUrl); return $this->sendEmail($email, $subject, $htmlBody); } public function sendPasswordResetEmail($email, $token) { $resetUrl = SITE_URL . "/reset-password.php?token=" . $token; $subject = "Reset Your Password - " . SITE_NAME; $htmlBody = $this->getPasswordResetEmailTemplate($resetUrl); return $this->sendEmail($email, $subject, $htmlBody); } private function sendEmail($to, $subject, $htmlBody) { $payload = [ 'personalizations' => [[ 'to' => [['email' => $to]], 'subject' => $subject ]], 'from' => ['email' => $this->fromEmail, 'name' => $this->fromName], 'content' => [['type' => 'text/html', 'value' => $htmlBody]] ]; $ch = curl_init('https://api.sendgrid.com/v3/mail/send'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $this->apiKey, 'Content-Type: application/json' ], CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => true ]); $response = curl_exec($ch); $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($statusCode === 202) { return true; } else { error_log("SendGrid email failed to $to: HTTP $statusCode — $response"); return false; } } private function getVerificationEmailTemplate($verificationUrl) { return '
India\'s Trusted Survey Platform
Thank you for registering with Relevant Reflex! To activate your account and start earning through paid surveys, please verify your email address by clicking the button below:
⏰ Note: This verification link expires in 48 hours.
If the button doesn\'t work, copy and paste this link into your browser:
If you did not create an account with Relevant Reflex, please ignore this email.
For support: support@relevantreflex.com
India\'s Trusted Survey Platform
We received a request to reset the password for your Relevant Reflex account. Click the button below to reset your password:
⏰ Note: This password reset link expires in 1 hour.
If the button doesn\'t work, copy and paste this link into your browser:
If you did not request a password reset, please ignore this email. Your password will not be changed.
For support: support@relevantreflex.com