parshavjain

Untitled

Aug 3rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. use PHPMailer\PHPMailer\Exception;
  4. if (isset($_POST['submit']))
  5. {
  6. $email=$_POST['email'];
  7. $message =$_POST['message'];
  8.  
  9.  
  10. require 'PHPMailer/src/Exception.php';
  11. require 'PHPMailer/src/PHPMailer.php';
  12. require 'PHPMailer/src/SMTP.php';
  13. $mail = new PHPMailer(); // create a new object
  14. $mail->IsSMTP(); // enable SMTP
  15. $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
  16. $mail->SMTPAuth = true; // authentication enabled // setting it to true
  17. $mail->SMTPSecure = 'SSL'; // secure transfer enabled REQUIRED for Gmail can also use 'TSL'
  18. $mail->Host = "smtp.gmail.com";// set a host
  19. $mail->Username="parshavjain98@gmail.com";
  20. $mail->Password="123parshav456";
  21. $mail->Port = 465; // or 587 if it is 'TSL'
  22. $mail->IsHTML(True);
  23. $mail->SetFrom($email,'Mailer'); // id used for sending the mail
  24. $mail->Subject = "";
  25. $mail->Body = $message;
  26. $mail->AddAddress('parshavjain98@gmail.com'); // receiver's email
  27. if ($mail->send()) {
  28. echo "mail is sent";
  29. } else {
  30. echo "there is an error in sending the mail";
  31. }
  32. }
  33. ?>
Add Comment
Please, Sign In to add comment