SHARE
TWEET

Untitled

a guest Jun 25th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form id="contact-form" method="post" action="contact.php">
  2. <input name="name" type="text" id="name" class="form-control" placeholder="Your name" required>
  3. <br>
  4. <input name="email" type="email" id="email" class="form-control" placeholder="Your email" required>
  5. <br>
  6.  
  7. <textarea name="message" id="message" class="form-control" placeholder="Message" row="4" required></textarea><br>
  8.  
  9.     <input type="submit" class="form-control submit" value="SEND MESSAGE">
  10.  
  11.     </form>
  12.      
  13. <?php
  14.  
  15. use PHPMailerPHPMailerPHPMailer;
  16. use PHPMailerPHPMailerException;
  17. require 'C:PHPMailerPHPMailer-mastersrcException.php';
  18. require 'C:PHPMailerPHPMailer-mastersrcPHPMailer.php';
  19. require 'C:PHPMailerPHPMailer-mastersrcSMTP.php';
  20.  
  21.  
  22. $mail = new PHPMailer(TRUE);
  23.  
  24. try {
  25.  
  26.    $mail->isHTML(true);
  27.     $mail->setFrom('example@hotmail.com', 'Contact Form');
  28.    $mail->addAddress('example@hotmail.com', 'Lewis');
  29.    $mail->isSMTP();
  30.    $mail->Host = 'smtp.gmail.com';
  31.    $mail->SMTPAuth = TRUE;
  32.    $mail->SMTPSecure = 'tls';
  33.   $mail->Username = '*******';
  34.    $mail->Password = '*****';
  35.    $mail->Port = 587;
  36.  
  37.    $name = $_POST['name'];
  38.    $email = $_POST['email'];
  39.    $message = $_POST['message'];
  40.  
  41.        if ($mail->addReplyTo($_POST['email'], $_POST['name'])) {
  42.         $mail->Subject = 'contact form';
  43.  
  44.  
  45.         $mail->isHTML(true);
  46.  
  47.     $mail->Body = "There has been a message sent from our contact form from: $name
  48.     <br>This is their message: $message
  49.     <br>Please respond to them here: $email";
  50.  
  51.  
  52.  
  53.  
  54.    //Send the message, check for errors
  55.         if (!$mail->send()) {
  56.             //The reason for failing to send will be in $mail->ErrorInfo
  57.  
  58.             $msg = 'Sorry, something went wrong. Please try again later.';
  59.         } else {
  60.             header("Refresh:3; url=index.php#contact");
  61.             echo "Message sent! Thanks for contacting us. We aim to respond within 1 working day";
  62.         }
  63.     } else {
  64.         $msg = 'Invalid email address, message ignored.';
  65.     }
  66.  
  67.  
  68.  
  69.  
  70.    /* Enable SMTP debug output. */
  71.    $mail->SMTPDebug = 4;
  72.  
  73.   // $mail->send();
  74.  
  75.  
  76. }
  77.  
  78. catch (Exception $e)
  79. {
  80.   echo $e->errorMessage();
  81. }
  82. catch (Exception $e)
  83. {
  84.    echo $e->getMessage();
  85.  
  86.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top