isSMTP(); $mail->Host = MAIL_HOST; $mail->SMTPAuth = true; $mail->Username = MAIL_USERNAME; $mail->Password = MAIL_PASSWORD; $mail->SMTPSecure = MAIL_ENCRYPTION === 'ssl' ? PHPMailer::ENCRYPTION_SMTPS : PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = MAIL_PORT; $mail->CharSet = 'UTF-8'; $mail->setFrom(MAIL_FROM, MAIL_FROM_NAME); $mail->addAddress($toEmail, $toName); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $htmlBody; $mail->AltBody = $textBody ?? strip_tags($htmlBody); $mail->send(); return ['success' => true, 'error' => '']; } catch (MailerException $e) { error_log('Mailer error to ' . $toEmail . ': ' . $mail->ErrorInfo); return ['success' => false, 'error' => $mail->ErrorInfo]; } } /** * Send a password reset email. */ function sendPasswordResetEmail(string $email, string $token): bool { $resetUrl = 'https://cropmonitor.com.au/login/reset-password.php?token=' . urlencode($token); $html = '
We received a request to reset your password. Click the button below to choose a new one.
This link expires in 1 hour. If you did not request a password reset, you can safely ignore this email.
Crop Monitor — Australian Crop Management Platform
Hi ' . htmlspecialchars($fullname, ENT_QUOTES, 'UTF-8') . ',
Your account has been created. You can now log in and start managing your crop analysis records.
If you have any questions, reply to this email and we will get back to you.
Crop Monitor — Australian Crop Management Platform