isSMTP(); $mail->SMTPAuth = true; $mail->Host = 'smtp.gmail.com'; $mail->Username = 'grandgeetpackers@gmail.com'; $mail->Password = 'dvrhnaatxjbxoqlj'; // Use an app password here instead of your Gmail password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = 587; //Recipients $mail->setFrom('grandgeetpackers@gmail.com', 'Grand Geet Packers'); $mail->addAddress('grandgeetpackers@gmail.com', 'User'); //Content $mail->isHTML(true); $mail->Subject = 'User Enquiry'; $mail->Body = " Shifting From: $shifting_from
Shifting To : $shifting_to
Phone: $phone
"; if ($mail->send()) { $_SESSION['status'] = "Thank you for sending mail! We will connect with you shortly."; } else { $_SESSION['status'] = "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } // Redirect to the form page with a session message header("Location: {$_SERVER['HTTP_REFERER']}"); exit(); } catch (Exception $e) { $_SESSION['status'] = "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; header("Location: {$_SERVER['HTTP_REFERER']}"); exit(); } } else { header("Location: {$_SERVER['HTTP_REFERER']}"); exit(); }