问题: 每个使用其电子邮件地址注册的用户都会收到三封重复的电子邮件。我的来宾名单被重复的电子邮件淹没了,我不知道我的代码出了什么问题。
可能原因: 我有3个注册表格,所以我认为当我提交一个注册表格时,它们都同时提交了。问题可能出在Bootstrap 4.1.3 JS或HTML中。
PHP代码:
$email = $_REQUEST['email'] ;
// 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;
require './PHPMailer-master/src/Exception.php';
require './PHPMailer-master/src/PHPMailer.php';
require './PHPMailer-master/src/SMTP.php';
// Popup Form Signup
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.domain.com";
$mail->SMTPAuth = true;
$mail->Username = "user@domain.com";
$mail->Password = "password";
$mail->SMTPSecure = 'TLS';
$mail->Port = 587;
$mail->From = $email;
$mail->setFrom('$email', 'Guest');
$mail->addAddress('admin@domain.com', 'Admin');
$mail->IsHTML(true);
$mail->Subject = "New Member!";
$mail->Body = $email;
$mail->AltBody = $email;
$mail2 = new PHPMailer();
$mail2->IsSMTP();
$mail2->Host = "mail.domain.com";
$mail2->SMTPAuth = true;
$mail2->Username = "user@domain.com";
$mail2->Password = "password";
$mail2->SMTPSecure = 'TLS';
$mail2->Port = 587;
$mail2->setFrom('support@domain.com', 'Support');
$mail2->AddAddress("$email");
$mail2->AddReplyTo('support@domain.com');
$mail2->Subject = "Thanks for signing up!";
$message = '';
$mail2->Body = $message;
$mail2->AltBody = $message;
if(!$mail2->Send())
{
echo "Message could not be sent. Please reload the page and try again. <p>";
echo "Mailer Error: " . $mail2->ErrorInfo;
exit;
}
if(!$mail->Send())
{
echo "Message was not received. Please reload the page and try again.<p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
我可以帮您翻译。以下是翻译结果,已保留HTML标签:
我还有其他表单打开不同的PHP文件,但它们不应该是这里的问题。我只是在这里添加了它,以防有人能找出什么问题。
表格1(相同的着陆页面)
<form class="signupForm1 input-group mt-1" method="post" action="topconfirm">
<div class="input-group">
<label for="email" class="sr-only">Enter your email address</label>
<input style ="overflow:hidden;" id="email" type="email" name="email" required class="sentence form-control" aria-label="Large" placeholder="enter your email address">
<button style="font-size:17px;" name="topsubmit" type="submit" class="ctabutton semibolder submitButton sentence text-white btn btn-secondary px-lg-3 px-md-1 px-sm-1 btn-lg rounded-0">Get Started</button>
</div>
</form>
表格2(同一着陆页)
(注:保留HTML标签,不提供解释)<form class="signupForm2 input-group mt-1" method="post" action="bottomconfirm">
<div class="input-group">
<label style="font-weight:normal!important;" for="email" class="sr-only">Enter your email address</label>
<input style ="overflow:hidden;" id="email" type="email" name="email" required class="sentence form-control" aria-label="Large" placeholder="enter your email address">
<input style="font-size:17px;" name="footersubmit" type="submit" class="ctabutton semibolder submitButton sentence text-white btn btn-secondary px-lg-3 px-md-1 px-sm-1 btn-lg rounded-0" value="Get Started"/>
</div>
</form>
我不是JavaScript或PHP邮件专家,请有经验的人帮忙解决这个问题,我认为它可能与Bootstrap JS 4.13有关。非常感谢您的任何建议和帮助。谢谢!