我有一个表单,允许用户注册一个访客列表。 在此之后,他们收到了确认邮件。 当我的表单被使用时,phpmailer将2封邮件发送给接收者。 验证完成后会包含此脚本。 你能告诉我出了什么问题吗?
<?php
//create connection
require_once 'connection.php';
/* ===================
variables
====================== */
$lastname = $_POST['lastname'];
$firstname = $_POST['firstname'];
$email = $_POST['email'];
/* ===================
sql data query
====================== */
//set query checking for duplicate entries
$nameQuery = "SELECT * FROM guestlist WHERE lastname LIKE '$lastname' AND firstname LIKE '$firstname' AND email LIKE '$email'";
//send checking query to database
$getName = mysqli_query($connection, $nameQuery)
or die ("fehlgeschlagen" .mysqli_connect_error());
//get result from database request
$resultGetName = mysqli_fetch_array($getName);
/* ===================
html message
====================== */
$mailSubjectInput = 'Confirmation';
$mailBodyInput = 'This is a Testmail';
/* ===================
mail function
====================== */
//PHPMailer setup
require_once 'libs/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
//$mail->SMTPDebug = 2; -- display dev/error messages
$mail->Host = $mailHost;
$mail->Username = $mailUser;
$mail->Password = $mailPW;
$mail->SMTPSecure = 'TLS';
$mail->Port = 25;
$mail->From = $mailSender;
$mail->FromName = $mailSenderName;
$mail->addReplyTo($mailSender, $mailSenderName);
$mail->addAddress($email, $firstname .' ' .$lastname);
// input
$mailSubject = utf8_decode($mailSubjectInput);
$mailContent = utf8_decode($mailBodyInput);
$mail->Subject = $mailSubject;
$mail->Body = $mailContent;
$mail->AltBody = $mailContent;
//var_dump($mail->send()); -- test if connection is true/false
$mail->send();