Advertisement
Guest User

Untitled

a guest
Aug 6th, 2018
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="de">
  3.  <head>
  4.   <meta charset="UTF-8">
  5.   <title>Datenschutzerklärung Mailer</title>
  6.  
  7.   <style>
  8.   body {
  9.    font-family: Verdana, Sans-Serif;
  10.    font-size: 14px;
  11.   }
  12.  
  13.   span.pflichtfeld {
  14.    font-size: 12px;
  15.    color: Red;
  16.   }
  17.  
  18.   blockquote {
  19.    width: 385px;
  20.   }
  21.   </style>
  22.  
  23.  </head>
  24. <body>
  25.  
  26.  
  27. <?php
  28. // Import PHPMailer classes into the global namespace
  29. // These must be at the top of your script, not inside a function
  30. use PHPMailer\PHPMailer\PHPMailer;
  31. use PHPMailer\PHPMailer\Exception;
  32.  
  33. //Load Composer's autoloader
  34. require 'vendor/autoload.php';
  35.  
  36. $Passwort = "L.";
  37.  
  38. if(isset($_POST))
  39.   {
  40.   $name = isset($_POST["name"]) ? strip_tags(trim($_POST["name"])) : ""; // Name
  41.   $email = isset($_POST["email"]) ? strip_tags(trim($_POST["email"])) : ""; // E-Mail
  42.   $betreff = isset($_POST["betreff"]) ? strip_tags(trim($_POST["betreff"])) : ""; // Betreff
  43.   $nachricht = isset($_POST["nachricht"]) ? strip_tags(trim($_POST["nachricht"])) : ""; // Nachricht
  44. }
  45.  
  46.  
  47. if(!empty($_POST['value1']))
  48. {
  49.     $name = 'Empfänger Name eingeben';
  50.     $email = 'E-mail des Empfängers eingeben';
  51.     $betreff = 'Datenschutzverordnungserklärung';
  52.     $nachricht = 'Bitte akzeptieren Sie unsere Datenschutzverordnung unter https:// bla';
  53. }
  54.  
  55.  
  56.  
  57.  
  58. // Benutzereingaben überprüfen
  59. // Die Meldungen müssen hier eventuell angepasst werden.
  60. $Fehler = ["Passwort"=>""];
  61. if (isset($_POST["submit"])) {
  62.  $Fehler["Passwort"] = $_POST["Passwort"] != $Passwort ? "Das Passwort ist ungültig!" : "";
  63. }
  64.  
  65. // Formular erstellen
  66. $Formular = "
  67. <form action='" . $_SERVER["SCRIPT_NAME"] . "' method='post'>
  68.  
  69. <h3>Datenschutzerklärung</h3>
  70.  
  71. <p>
  72. <label> Name:
  73. <br>
  74.  <input type='text' name='name' value='" . $name . "' size='35'>
  75. </label>
  76. </p>
  77.  
  78. <p>
  79. <label> E-Mail:
  80. <br>
  81.  <input type='text' name='email' value='" . $email . "' size='35'>
  82. </label>
  83. </p>
  84.  
  85. <p>
  86. <label> Betreff:
  87. <br>
  88.  <input type='text' name='betreff' value='" . $betreff . "' size='35'>
  89. </label>
  90. </p>
  91.  
  92. <p>
  93. <label> Nachricht:
  94. <br>
  95.  <input type='text' name='nachricht' value='" . $nachricht . "' size='35'>
  96. </label>
  97. </p>
  98.  
  99. <p>
  100. <label> Passwort:
  101. <span class='pflichtfeld'>&#10034; " . $Fehler["Passwort"] . "</span><br>
  102. <input type='password' name='Passwort' size='20' value='" . (isset($_POST["Passwort"]) ? $_POST["Passwort"] : "") . "'>
  103. </label>
  104. </p>
  105.  
  106. <p>
  107. <br>
  108. <input type='submit' name='vorschau' value='Vorschau'> -
  109. <input type='submit' name='submit' value='Formular absenden'>
  110. </p>
  111.  
  112. <p>
  113. <small>Bitte alle mit <span class='pflichtfeld'>&#10034;</span>
  114. markierten Felder ausfüllen.</small>
  115. </p>
  116.  
  117. </form>
  118. ";
  119.  
  120. // Vorschau
  121. if (isset($_POST["vorschau"])) {
  122.  echo strip_tags("<blockquote>
  123. <h4>Vorschau</h4>
  124. <b>Name:</b> $name <br>
  125. <b>E-Mail:</b> $email <br>
  126. <b>Betreff:</b> $betreff <br>
  127. <b>Nachricht:</b> $nachricht
  128. </blockquote>", "<blockquote><h4><b><br>");
  129. }
  130.  
  131. // Formular abgesendet
  132. if (isset($_POST["submit"])) {
  133.  
  134.  // Sind keine Benutzer-Eingabefehler vorhanden
  135.  if (implode("", $Fehler) == "") {
  136.  
  137. $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
  138. try {
  139.     //Server settings
  140.     $mail->SMTPDebug = 2;                                 // Enable verbose debug output
  141.     $mail->isSMTP();                                      // Set mailer to use SMTP
  142.     $mail->Host = 'send.one.com';  // Specify main and backup SMTP servers
  143.     $mail->SMTPAuth = true;                               // Enable SMTP authentication
  144.     $mail->Username = 'pr@ab-it-group.de';                 // SMTP username
  145.     $mail->Password = '';                           // SMTP password
  146.     $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  147.     $mail->Port = 587;                                    // TCP port to connect to
  148.  
  149.     //Recipients
  150.     $mail->setFrom('info@ab-it-group.de', 'Mailer');
  151.     $mail->addAddress($email, $name);     // Add a recipient
  152.     $mail->addReplyTo('info@ab-it-group.de', 'Information');
  153.     // $mail->addCC('cc@example.com');
  154.     // $mail->addBCC('bcc@example.com');
  155.  
  156.     //Attachments
  157.     $mail->addAttachment('/var/www/html/datenschutz.pdf');         // Add attachments
  158.     // $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  159.  
  160.     //Content
  161.     $mail->isHTML(true);                                  // Set email format to HTML
  162.     $mail->Subject = $betreff;
  163.     $mail->Body    = $nachricht;
  164.     //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  165.  
  166.     $mail->send();
  167.     echo 'Message has been sent';
  168. } catch (Exception $e) {
  169.     echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  170. }
  171. }
  172.  echo $Formular;
  173. }
  174. ?>
  175. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement