Guest User

Untitled

a guest
Jul 27th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailerPHPMailerPHPMailer;
  4. use PHPMailerPHPMailerException;
  5.  
  6. //Load Composer's autoloader
  7. require 'vendor/autoload.php';
  8.  
  9.  
  10.  
  11. if(isset( $_POST['name']))
  12. $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
  13. if(isset( $_POST['vorname']))
  14. $name = filter_var($_POST['vorname'], FILTER_SANITIZE_STRING);
  15. if(isset( $_POST['email']))
  16. $email = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
  17. if(isset( $_POST['message']))
  18. $message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
  19. if(isset( $_POST['subject']))
  20. $subject = filter_var($_POST['subject'], FILTER_SANITIZE_STRING);
  21.  
  22.  
  23. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  24. try {
  25. //Server settings
  26. $mail->SMTPDebug = 2; // Enable verbose debug output
  27. $mail->isSMTP(); // Set mailer to use SMTP
  28. $mail->Host = 'XXX'; // Specify main and backup SMTP servers
  29. $mail->SMTPAuth = true; // Enable SMTP authentication
  30. $mail->Username = 'behar@zenuni.ch'; // SMTP username
  31. $mail->Password = 'XXX'; // SMTP password
  32. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  33. $mail->Port = 587; // TCP port to connect to
  34.  
  35. //sender
  36. $mail->setFrom($email, $name);
  37.  
  38. //empfänger
  39. $mail->addAddress('behar@zenuni.ch', 'Behar Zenuni'); // Add a recipient
  40.  
  41. //body content
  42. $body = "<p><strong>Sie haben eine Nachricht erhlaten:</strong> <br><br> " . $message . "</p>";
  43.  
  44.  
  45. //Content
  46. $mail->isHTML(true); // Set email format to HTML
  47. $mail->Subject = ' ' . $subject;
  48.  
  49. $mail->Body = $body;
  50. //$mail->AltBody = strip_tags($body);
  51.  
  52. $mail->send();
  53. echo 'Message has been sent';
  54. //header("location: index.php?sent"); -> relocate to index.php
  55. header("location: thankyou.php");
  56.  
  57.  
  58. } catch (Exception $e) {
  59. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  60. }
  61.  
  62. html>
  63. <html lang="en">
  64.  
  65. <head>
  66. <meta charset="UTF-8">
  67. <title>Zenuni Company</title>
  68. <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
  69. <link rel="stylesheet" href="bootstrap.css">
  70. <link rel="stylesheet" href="app.css">
  71. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  72. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
  73. </head>
  74.  
  75. <body>
  76. <div class="container h-100" id="con1">
  77. <img src="">
  78. <div class="row">
  79. <div class="col-12">
  80. <div id="content">
  81. <h1>The Zenuni Company</h1>
  82. <h3>Contact Us</h3>
  83. <hr>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88.  
  89. <section class="section">
  90. <div class="container">
  91. <div class="col-md-12 mb-md-10 mb-10">
  92.  
  93. <form id="contact-form" name="contact-form" action="mail.php" method="POST">
  94.  
  95. <div class="row">
  96. <div class="form-group col-md-3 offset-md-3">
  97. <input class="form-control transparent-input" type="text" id="name" name="name" placeholder="Name" required>
  98. </div>
  99. <div class="form-group col-md-3">
  100. <input class="form-control transparent-input" type="text" id="vorname" name="vorname" placeholder="Vorname" required>
  101. </div>
  102. <div class="form-group col-md-3 offset-md-3">
  103. <input class="form-control transparent-input" type="email" id="email" name="email" placeholder="Email" required>
  104. </div>
  105. <div class="form-group col-md-3">
  106. <input class="form-control transparent-input" type="text" id="subject" name="subject" placeholder="Subject" required>
  107. </div>
  108. <div class="form-group col-md-6 offset-md-3">
  109. <textarea class="form-control transparent-input" type="text" id="message" name="message" cols="20" rows="10" placeholder="Enter your message" required></textarea>
  110. </div>
  111. <div class="form-group col-md-6 offset-md-3">
  112. <button id="mybtn" type="submit" class="btn btn-primary">Send</button>
  113. </div>
  114. </div>
  115.  
  116. </form>
  117.  
  118. </div>
  119. </div>
  120. </div>
  121. </section>
  122.  
  123.  
  124. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
  125. </body>
  126. </html>
Add Comment
Please, Sign In to add comment