isSMTP(); $mail->Host = getenv('SMTP_HOST'); $mail->SMTPAuth = true; $mail->Port = (int) getenv('SMTP_PORT'); $mail->SMTPSecure = $mail->Port === 465 ? PHPMailer::ENCRYPTION_SMTPS : PHPMailer::ENCRYPTION_STARTTLS; $mail->Username = getenv('SMTP_USERNAME'); $mail->Password = getenv('SMTP_PASSWORD'); $mail->SMTPOptions = [ 'ssl' => [ 'cafile' => '/etc/ssl/certs/ca-certificates.crt', 'verify_peer' => true, 'verify_peer_name' => true, ], ]; $mail->setFrom(getenv('SMTP_FROM_EMAIL'), getenv('SMTP_FROM_NAME')); $mail->isHTML(true); return $mail; } function sendEmailVerificationEmail(string $toEmail, string $username, string $verifyLink): bool { try { $mail = configureAppMailer(); $mail->addAddress($toEmail, $username); $mail->Subject = 'Verify your email to start creating critters'; $safeUsername = htmlspecialchars($username, ENT_QUOTES, 'UTF-8'); $safeVerifyLink = htmlspecialchars($verifyLink, ENT_QUOTES, 'UTF-8'); $mail->Body = '
Your OurApp account has been created. Verify your email to unlock your free credits and start creating unique, AI-generated critters — pick an adjective, animal, action, and location, and watch your imagination come to life.
If you didn’t create this account, you can safely ignore this email.
Hi ' . $safeUsername . ', we received a request to reset your OurApp password. Click the button below to choose a new one. This link expires in 20 minutes.
If you didn’t request a password reset, you can safely ignore this email — your password will not be changed.