isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = getenv("SMTP_EMAIL"); // Get email from environment variable $mail->Password = getenv("SMTP_PASSWORD"); // Get password from environment variable $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; // Set email details $mail->setFrom($email, $name); $mail->addAddress(getenv("RECEIVER_EMAIL")); // Receiver's email $mail->Subject = "New Contact Form Submission from $name"; $mail->Body = "From: $name <$email>\n\n$message"; // Send email $mail->send(); echo "Message sent successfully!"; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } } ?>