Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="UTF-8">
- <title>Datenschutzerklärung Mailer</title>
- <style>
- body {
- font-family: Verdana, Sans-Serif;
- font-size: 14px;
- }
- span.pflichtfeld {
- font-size: 12px;
- color: Red;
- }
- blockquote {
- width: 385px;
- }
- </style>
- </head>
- <body>
- <?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';
- $Passwort = "L.";
- if(isset($_POST))
- {
- $name = isset($_POST["name"]) ? strip_tags(trim($_POST["name"])) : ""; // Name
- $email = isset($_POST["email"]) ? strip_tags(trim($_POST["email"])) : ""; // E-Mail
- $betreff = isset($_POST["betreff"]) ? strip_tags(trim($_POST["betreff"])) : ""; // Betreff
- $nachricht = isset($_POST["nachricht"]) ? strip_tags(trim($_POST["nachricht"])) : ""; // Nachricht
- }
- if(!empty($_POST['value1']))
- {
- $name = 'Empfänger Name eingeben';
- $email = 'E-mail des Empfängers eingeben';
- $betreff = 'Datenschutzverordnungserklärung';
- $nachricht = 'Bitte akzeptieren Sie unsere Datenschutzverordnung unter https:// bla';
- }
- // Benutzereingaben überprüfen
- // Die Meldungen müssen hier eventuell angepasst werden.
- $Fehler = ["Passwort"=>""];
- if (isset($_POST["submit"])) {
- $Fehler["Passwort"] = $_POST["Passwort"] != $Passwort ? "Das Passwort ist ungültig!" : "";
- }
- // Formular erstellen
- $Formular = "
- <form action='" . $_SERVER["SCRIPT_NAME"] . "' method='post'>
- <h3>Datenschutzerklärung</h3>
- <p>
- <label> Name:
- <br>
- <input type='text' name='name' value='" . $name . "' size='35'>
- </label>
- </p>
- <p>
- <label> E-Mail:
- <br>
- <input type='text' name='email' value='" . $email . "' size='35'>
- </label>
- </p>
- <p>
- <label> Betreff:
- <br>
- <input type='text' name='betreff' value='" . $betreff . "' size='35'>
- </label>
- </p>
- <p>
- <label> Nachricht:
- <br>
- <input type='text' name='nachricht' value='" . $nachricht . "' size='35'>
- </label>
- </p>
- <p>
- <label> Passwort:
- <span class='pflichtfeld'>✲ " . $Fehler["Passwort"] . "</span><br>
- <input type='password' name='Passwort' size='20' value='" . (isset($_POST["Passwort"]) ? $_POST["Passwort"] : "") . "'>
- </label>
- </p>
- <p>
- <br>
- <input type='submit' name='vorschau' value='Vorschau'> -
- <input type='submit' name='submit' value='Formular absenden'>
- </p>
- <p>
- <small>Bitte alle mit <span class='pflichtfeld'>✲</span>
- markierten Felder ausfüllen.</small>
- </p>
- </form>
- ";
- // Vorschau
- if (isset($_POST["vorschau"])) {
- echo strip_tags("<blockquote>
- <h4>Vorschau</h4>
- <b>Name:</b> $name <br>
- <b>E-Mail:</b> $email <br>
- <b>Betreff:</b> $betreff <br>
- <b>Nachricht:</b> $nachricht
- </blockquote>", "<blockquote><h4><b><br>");
- }
- // Formular abgesendet
- if (isset($_POST["submit"])) {
- // Sind keine Benutzer-Eingabefehler vorhanden
- if (implode("", $Fehler) == "") {
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 2; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'send.one.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'pr@ab-it-group.de'; // SMTP username
- $mail->Password = ''; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- //Recipients
- $mail->setFrom('info@ab-it-group.de', 'Mailer');
- $mail->addAddress($email, $name); // Add a recipient
- $mail->addReplyTo('info@ab-it-group.de', 'Information');
- // $mail->addCC('cc@example.com');
- // $mail->addBCC('bcc@example.com');
- //Attachments
- $mail->addAttachment('/var/www/html/datenschutz.pdf'); // Add attachments
- // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = $betreff;
- $mail->Body = $nachricht;
- //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- }
- echo $Formular;
- }
- ?>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement