Guest User

Untitled

a guest
Feb 19th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.36 KB | None | 0 0
  1. <?php
  2.  
  3. if(!empty($_POST)) {
  4.     require 'PHPMailerAutoload.php';
  5.  
  6.     $mail = new PHPMailer;
  7.  
  8.     //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  9.  
  10.     $mail->isSMTP();                                      // Set mailer to use SMTP
  11.     $mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
  12.     $mail->SMTPAuth = true;                               // Enable SMTP authentication
  13.     $mail->Username = 'user@example.com';                 // SMTP username
  14.     $mail->Password = 'secret';                           // SMTP password
  15.     $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  16.     $mail->Port = 587;                                    // TCP port to connect to
  17.  
  18.     $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
  19.     $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
  20.     $phone = filter_var($_POST['phone'], FILTER_SANITIZE_STRING);
  21.     $department = filter_var($_POST['department'], FILTER_SANITIZE_STRING);
  22.     $description = filter_var($_POST['description'], FILTER_SANITIZE_STRING);
  23.     if (empty($name) || empty($email) || empty($department) || empty($description)) {
  24.         echo "Name, email and message required, please correct the errors and resubmit.";
  25.     }else {
  26.         if ($department == "DMCA") {
  27.             $to = "dmca@craigventures.com";
  28.         }
  29.         else if ($department == "Management") {
  30.             $to = "management@craigventures.com";
  31.         }
  32.         else if ($department == "Technical") {
  33.             $to = "technical@craigventures.com";
  34.         }
  35.         else {
  36.             $to = "support@craigventures.com";
  37.         }
  38.         $mail->addAddress($to);
  39.         $mail->Subject = "Contact Form Submission (craigventures.com)";
  40.         $mail->setFrom($email, $name);
  41.         $mail->addReplyTo($email);
  42.         $mail->isHTML(true);
  43.         $message = "<html><body>";
  44.         $message .= "<b>Name: </b>$name<br>
  45.                   <b>Email: </b> $email<br>
  46.                   <b>Phone: </b> $phone<br>
  47.                   <b>Department: </b> $department<br>
  48.                   <b>Message: </b> $description
  49.                   ";
  50.         $message .= "</body></html>";
  51.         $mail->Body = $message;
  52.         if(!$mail->send()) {
  53.             echo 'Message could not be sent.';
  54.             echo 'Mailer Error: ' . $mail->ErrorInfo;
  55.         } else {
  56.             echo "<div class='alert'>Your message has been sent and we aim to get back to you within 24 hours.</div>";
  57.         }
  58.     }
  59. }
  60. ?>
  61.  
  62. <div class="contactform">
  63.     <form action="" method="POST" enctype="multipart/form-data">
  64.         <div class="contactinfo">
  65.             <input type="hidden" name="action" value="submit">
  66.             <fieldset class="formsection">
  67.                 <label for="name">Your Name</label><br>
  68.                 <input type="text" name="name" id="Name" placeholder="Enter your name here" required>
  69.             </fieldset>
  70.             <fieldset class="formsection">
  71.                 <label for="email">Your Email</label><br>
  72.                 <input type="email" name="email" id="Email" placeholder="Enter your email here" required>
  73.             </fieldset>
  74.             <fieldset class="formsection">
  75.                 <label for="phone">Phone Number</label><br>
  76.                 <input type="text" name="phone" id="Phone" placeholder="Enter your phone number">
  77.             </fieldset>
  78.             <fieldset class="formsection">
  79.                 <label for="department">Department</label><br>
  80.                 <select name="department" id="Department">
  81.                     <option value="Support">General Support</option>
  82.                     <option value="Technical">Technical Assistance</option>
  83.                     <option value="DMCA">DMCA</option>
  84.                     <option value="Management">Management</option>
  85.                 </select>
  86.             </fieldset>
  87.         </div>
  88.         <div class="contactmessage">
  89.             <fieldset class="formsection">
  90.                 <label for="message">Your Message</label><br>
  91.                 <textarea name="description" id="Description" rows="7" placeholder="Your message to us..." required></textarea>
  92.             </fieldset>
  93.         </div>
  94.          <div class="contactsubmit">
  95.             <button type="submit">Submit</button>
  96.         </div>
  97.     </form>
  98. </div>
Add Comment
Please, Sign In to add comment