SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = 'ssps6057@gmail.com'; //SMTP username $mail->Password = 'aelshaclihqayxxu'; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('ssps6057@gmail.com', 'Mailer'); $mail->addAddress('utsav6626@gmail.com', 'User'); //Add a recipient //Name is optional //Optional name //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = 'User Inquiry'; $mail->Body = " User Name: $name
Email: $email
Subject: $subject
Phone: $phone
Message: $message
" ; if($mail->send()){ $_SESSION['status'] = 'Message has been sent'; header("Location:contact.php"); } else{ $_SESSION['status'] = "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; header("Location:contact.php"); } } catch (Exception $e) { $_SESSION['status'] = "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } } else { header("Location: {$_SERVER['HTTP_REFERER']}"); exit(); }