Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!empty($_POST)) {
- require 'PHPMailerAutoload.php';
- $mail = new PHPMailer;
- //$mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'user@example.com'; // SMTP username
- $mail->Password = 'secret'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
- $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
- $phone = filter_var($_POST['phone'], FILTER_SANITIZE_STRING);
- $department = filter_var($_POST['department'], FILTER_SANITIZE_STRING);
- $description = filter_var($_POST['description'], FILTER_SANITIZE_STRING);
- if (empty($name) || empty($email) || empty($department) || empty($description)) {
- echo "Name, email and message required, please correct the errors and resubmit.";
- }else {
- if ($department == "DMCA") {
- $to = "dmca@craigventures.com";
- }
- else if ($department == "Management") {
- $to = "management@craigventures.com";
- }
- else if ($department == "Technical") {
- $to = "technical@craigventures.com";
- }
- else {
- $to = "support@craigventures.com";
- }
- $mail->addAddress($to);
- $mail->Subject = "Contact Form Submission (craigventures.com)";
- $mail->setFrom($email, $name);
- $mail->addReplyTo($email);
- $mail->isHTML(true);
- $message = "<html><body>";
- $message .= "<b>Name: </b>$name<br>
- <b>Email: </b> $email<br>
- <b>Phone: </b> $phone<br>
- <b>Department: </b> $department<br>
- <b>Message: </b> $description
- ";
- $message .= "</body></html>";
- $mail->Body = $message;
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo "<div class='alert'>Your message has been sent and we aim to get back to you within 24 hours.</div>";
- }
- }
- }
- ?>
- <div class="contactform">
- <form action="" method="POST" enctype="multipart/form-data">
- <div class="contactinfo">
- <input type="hidden" name="action" value="submit">
- <fieldset class="formsection">
- <label for="name">Your Name</label><br>
- <input type="text" name="name" id="Name" placeholder="Enter your name here" required>
- </fieldset>
- <fieldset class="formsection">
- <label for="email">Your Email</label><br>
- <input type="email" name="email" id="Email" placeholder="Enter your email here" required>
- </fieldset>
- <fieldset class="formsection">
- <label for="phone">Phone Number</label><br>
- <input type="text" name="phone" id="Phone" placeholder="Enter your phone number">
- </fieldset>
- <fieldset class="formsection">
- <label for="department">Department</label><br>
- <select name="department" id="Department">
- <option value="Support">General Support</option>
- <option value="Technical">Technical Assistance</option>
- <option value="DMCA">DMCA</option>
- <option value="Management">Management</option>
- </select>
- </fieldset>
- </div>
- <div class="contactmessage">
- <fieldset class="formsection">
- <label for="message">Your Message</label><br>
- <textarea name="description" id="Description" rows="7" placeholder="Your message to us..." required></textarea>
- </fieldset>
- </div>
- <div class="contactsubmit">
- <button type="submit">Submit</button>
- </div>
- </form>
- </div>
Add Comment
Please, Sign In to add comment