<?php
header('Content-type: text/html; charset=utf-8');require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$mail->ContentType = 'text/html';
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->Host = "HIER HOST EINFÜGEN";
$mail->Port = 25;
$mail->Username = "BENUTZERNAME";
$mail->Password = "PASSWORT";
$mail->SetFrom('From Adresse', 'FROM NAME');
$mail->Subject = "TITEL";
$mail->Body = "TEXT";
$address = zielemailadresse;
$mail->AddAddress($address, Zielname);
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Mail Erfolgreich gesendet";
}
Das ist mein Code:
<head> <meta name="robots" content="noindex"> <meta charset="utf-8"> <title></title> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/stylesheet.css" rel="stylesheet"> <link href="img/icons/favicon.ico" rel="shortcut icon"> </head> <body> <?php $empfaenger = "test@testl.de"; $absendername = htmlspecialchars($_POST["name"]); $absendermail = $_POST["email"]; $betreff = "Kontaktformular"; $eingabe = htmlspecialchars($_POST["eingabe"]); $text = "Nachricht von $absendername. E-Mail: $absendermail. Nachricht: $eingabe"; if(!empty($absendername) and !empty($absendermail) and !empty($eingabe) and filter_var($absendermail, FILTER_VALIDATE_EMAIL)) { mail($empfaenger, $betreff, $text, "From: $absendername <$absendermail>"); echo "<h1 style='text-align: center;padding-top:100px'>Danke für deine Nachricht!</h1>" . "<h2 style='text-align: center'><a href=http://test.de/>Zurück</a></h2>"; } else echo "Eingabe nicht erfolgreich, Versuchen sie es Nocheinmal<meta http-equiv='refresh' content='3; URL=http://test.de/'>"; ?>#