Advertisement
Guest User

Untitled

a guest
Jan 12th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.35 KB | None | 0 0
  1. <?php
  2.  
  3.     require '../_lib/phpmailer/PHPMailerAutoload.php';
  4.  
  5.     // CONFIG YOUR FIELDS
  6.     //============================================================
  7.     $firstname =     filter_var($_POST["firstname"], FILTER_SANITIZE_STRING);
  8.     $lastname =     filter_var($_POST["lastname"], FILTER_SANITIZE_STRING);
  9.     $company =     filter_var($_POST["company"], FILTER_SANITIZE_STRING);
  10.     $email =    filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
  11.     $formMessage =  filter_var($_POST["message"], FILTER_SANITIZE_STRING);
  12.  
  13.     // CONFIG YOUR EMAIL MESSAGE
  14.     //============================================================
  15.     $message = '<p>The following request was sent from turingvr.com: </p>';
  16.     $message .= '<p>Name: ' . $firstname . ' ' . $lastname .'</p>';
  17.     $message .= '<p>Company: ' . $company .'</p>';
  18.     $message .= '<p>Email: ' . $email . '</p>';
  19.     $message .= '<p>Message: ' . $formMessage .'</p>';
  20.  
  21.     // CONFIG YOUR MAIL SERVER
  22.     //============================================================
  23.     $mail = new PHPMailer;
  24.     $mail->isSMTP();                                    // Enable SMTP authentication
  25.     $mail->SMTPAuth = true;                             // Set mailer to use SMTP
  26.     $mail->Host = 'musk.arvixe.com';                // Specify main and backup server
  27.  
  28.     $mail->Username = 'hello@turingvr.com';                  // SMTP username
  29.     $mail->Password = '***';                         // SMTP password
  30.     $mail->SMTPSecure = 'ssl';                          // Enable encryption, 'ssl' also accepted
  31.     $mail->Port = 465;
  32.  
  33.     $mail->From = $email;
  34.     $mail->FromName = $name;
  35.     $mail->AddReplyTo($email,$name);
  36.     $mail->addAddress('tyler@turingvr.com', $name);  // Add a recipient
  37.  
  38.     $mail->WordWrap = 50;                               // Set word wrap to 50 characters
  39.     $mail->isHTML(true);                                // Set email format to HTML
  40.  
  41.     $mail->Subject = 'New message from turingvr.com';
  42.     $mail->Body    = $message;
  43.     $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  44.  
  45.     if(!$mail->send()) {
  46.         $data['error']['title'] = 'Message could not be sent.';
  47.         $data['error']['details'] = 'Mailer Error: ' . $mail->ErrorInfo;
  48.        exit;
  49.     }
  50.  
  51.     $data['success']['title'] = 'Message has been sent';
  52.  
  53.     echo json_encode($data);
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement