Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- if (isset($_POST['submit']))
- {
- $email=$_POST['email'];
- $message =$_POST['message'];
- require 'PHPMailer/src/Exception.php';
- require 'PHPMailer/src/PHPMailer.php';
- require 'PHPMailer/src/SMTP.php';
- $mail = new PHPMailer(); // create a new object
- $mail->IsSMTP(); // enable SMTP
- $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
- $mail->SMTPAuth = true; // authentication enabled // setting it to true
- $mail->SMTPSecure = 'SSL'; // secure transfer enabled REQUIRED for Gmail can also use 'TSL'
- $mail->Host = "smtp.gmail.com";// set a host
- $mail->Username="parshavjain98@gmail.com";
- $mail->Password="123parshav456";
- $mail->Port = 465; // or 587 if it is 'TSL'
- $mail->IsHTML(True);
- $mail->SetFrom($email,'Mailer'); // id used for sending the mail
- $mail->Subject = "";
- $mail->Body = $message;
- $mail->AddAddress('parshavjain98@gmail.com'); // receiver's email
- if ($mail->send()) {
- echo "mail is sent";
- } else {
- echo "there is an error in sending the mail";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment