false, 'message' => 'Please fill in all required fields and try again.']); exit; } // Create new PHPMailer object $mail = new PHPMailer(true); try { // SMTP settings for sending via Gmail $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; // Gmail server $mail->SMTPAuth = true; $mail->Username = 'scandrone308@gmail.com'; // Your Gmail address for sending $mail->Password = 'your_app_password'; // App password (explained below) $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Encryption (SSL) $mail->Port = 465; // Gmail port // Who will receive the email $mail->setFrom('from@yourwebsite.com', 'Website Contact Form'); // Dummy sender email $mail->addAddress('bayan10kh@gmail.com', 'Bayan'); // Your email to receive messages // Email content $mail->isHTML(true); // Enable HTML in email $mail->Subject = 'New message from contact form'; // Build message body $email_content = "
Name: {$name}
"; $email_content .= "Email: {$email}
"; $email_content .= "Phone: {$phone}
"; $email_content .= "Message:
{$message}