Letlabo Nature Reserve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

contact.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. use PHPMailer\PHPMailer\Exception;
  4. require 'C:\xampp\composer\vendor\autoload.php';
  5. if(isset($_POST['submit'])) {
  6. $name = $_POST['name'];
  7. $email = $_POST['email'];
  8. $phone = $_POST['phone'];
  9. $subject = $_POST['subject'];
  10. $message = $_POST['message'];
  11. $mail = new PHPMailer(true);
  12. $mail->SMTPDebug = 2; // Enable debugging
  13. $mail->isSMTP();
  14. $mail->Host = 'smtp.gmail.com';
  15. $mail->SMTPAuth = true;
  16. $mail->Username = 'infoletlabo@gmail.com';
  17. $mail->Password = 'Garfield@13';
  18. $mail->SMTPSecure = 'tls'; // Enable SSL secure email
  19. $mail->Port = 587; // Port no may change
  20. //Recipients
  21. $mail->setFrom($email, $name); // User email
  22. $mail->addAddress('infoletlabo@gmail.com', 'Letlabo Nature Reserve'); // Your email
  23. $mail->addcc ($email);
  24. $mail->addReplyTo($email, $name); // Replay to User
  25. //Content
  26. $mail->isHTML(False);
  27. $mail->Subject = $subject;
  28. $mail->Body ='Equiry From: '.$name."\r\n".'Message: ' .$message."\r\n". 'Reply To: ' .$email."\r\n". 'Contact on: '.$phone;
  29. ;
  30. if($mail->send()) {
  31. echo "<script type='text/javascript'>alert('submitted successfully!')</script>";
  32. }
  33. else
  34. {
  35. echo "<script type='text/javascript'>alert('failed!')</script>";
  36. }
  37. header('Location: contact.html');
  38. exit;
  39. }
  40. ?>