isSMTP(); //Send using SMTP $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through $mail->Username = 'ravitiwari.ssp@gmail.com'; //SMTP username $mail->Password = 'xrqomokjlfjlsdcl'; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable implicit TLS encryption $mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('ravitiwari.ssp@gmail.com', 'Hello'); $mail->addAddress('ravitiwari.ssp@gmail.com', 'User'); //Add a recipient //Content $mail->isHTML(true); //Set email format to HTML $mail->Subject = 'User Enquiry'; $mail->Body = " Service : $service
Phone Number : $phone
Date : $date
"; if($mail->send()){ $_SESSION['status'] = "Thank you for sending mail"; header("Location: index.php"); exit(0); }else{ $_SESSION['status'] = "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; header("Location: index.php"); exit(0); } } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } }else{ header("Location: index.php"); } ?>