Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Import PHPMailer classes into the global namespace
- // These must be at the top of your script, not inside a function
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- //Load composer's autoloader
- require 'vendor/autoload.php';
- //Load variable with password
- require 'credentials.php';
- $subject = $_POST['selection'];
- $name = $_POST['name'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- // Passing `true` enables exceptions
- $mail = new PHPMailer(true);
- try {
- //Server settings
- //Enable SMTP debugging
- // 0 = off (for production use)
- // 1 = client messages
- // 2 = client and server messages
- $mail->SMTPDebug = 0;
- $mail->isSMTP();
- //Sets SMTP Host
- $mail->Host = gethostbyname('mail.luukkenselaar.nl');
- $mail->SMTPAuth = true;
- $mail->Username = 'gamepc@luukkenselaar.nl';
- // Retrieve password from SECRET var
- $mail->Password = $secret;
- $mail->SMTPSecure = 'tls';
- $mail->SMTPAuth = true;
- $mail->Port = 587;
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- //Recipients
- $mail->setFrom('gamepc@luukkenselaar.nl', "Webshop");
- $mail->addAddress('luuk2014@hotmail.com');
- //Content
- $mail->isHTML(true);
- $mail->Subject = "Webshop Contact";
- $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";
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
- // Set here redirect page or destination page
- header("Location: ../contact.php?send");
- //Made by Luuk Kenselaar 2017
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement