Advertisement
Guest User

Untitled

a guest
Apr 4th, 2018
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. <?php
  2. // Import PHPMailer classes into the global namespace
  3. // These must be at the top of your script, not inside a function
  4. use PHPMailer\PHPMailer\PHPMailer;
  5. use PHPMailer\PHPMailer\Exception;
  6.  
  7. //Load composer's autoloader
  8. require 'vendor/autoload.php';
  9. //Load variable with password
  10. require 'credentials.php';
  11.  
  12. $subject = $_POST['selection'];
  13. $name = $_POST['name'];
  14. $email = $_POST['email'];
  15. $message = $_POST['message'];
  16.  
  17. // Passing `true` enables exceptions
  18. $mail = new PHPMailer(true);                                    
  19. try {
  20.     //Server settings
  21.     //Enable SMTP debugging
  22.     // 0 = off (for production use)
  23.     // 1 = client messages
  24.     // 2 = client and server messages
  25.     $mail->SMTPDebug = 0;
  26.     $mail->isSMTP();
  27.     //Sets SMTP Host
  28.     $mail->Host = gethostbyname('mail.luukkenselaar.nl');
  29.     $mail->SMTPAuth = true;
  30.     $mail->Username = 'gamepc@luukkenselaar.nl';
  31.     // Retrieve password from SECRET var
  32.     $mail->Password = $secret;                                  
  33.     $mail->SMTPSecure = 'tls';
  34.     $mail->SMTPAuth = true;
  35.     $mail->Port = 587;
  36.     $mail->SMTPOptions = array(
  37.         'ssl' => array(
  38.             'verify_peer' => false,
  39.             'verify_peer_name' => false,
  40.             'allow_self_signed' => true
  41.         )
  42.     );
  43.    
  44.     //Recipients
  45.     $mail->setFrom('gamepc@luukkenselaar.nl', "Webshop");
  46.     $mail->addAddress('luuk2014@hotmail.com');
  47.    
  48.     //Content
  49.     $mail->isHTML(true);
  50.     $mail->Subject = "Webshop Contact";
  51.     $mail->Body = "Someone on the website used the contact form: <br/><br/> Subject: $subject <br/> Name: $name <br/> Email: $email <br/> Ordernumber: $ordernumber <br/> Message: $message";
  52.  
  53.     $mail->send();
  54.     echo 'Message has been sent';
  55. } catch (Exception $e) {
  56.     echo 'Message could not be sent.';
  57.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  58. }
  59.     // Set here redirect page or destination page
  60.     header("Location: ../contact.php?send");
  61. //Made by Luuk Kenselaar 2017
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement