gpt4 book ai didi

php - 使用 PHPmailer 从网站发送消息时遇到错误

转载 作者:太空宇宙 更新时间:2023-11-04 10:40:42 26 4
gpt4 key购买 nike

我正在尝试修复错误,但我做不到。互联网上有很多关于 PHPmailer 的资料我试过了,但我的网站不发送消息。请修正错误。我正在粘贴我的代码。也请告诉我其他发送消息的方法。

<div class="row">
<div class="col-lg-8">
<div class="boxed-grey">
<form id="contact-form">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<form action="ContactFormHandler.php"
method="post">
<label for="name">
Name</label>
<input type="text" class="form-control"
id="name" placeholder="Enter name" required="required" />
</div>
<div class="form-group">
<label for="email">
Email Address</label>
<div class="input-group">
<span class="input-group-addon"><span
class="glyphicon glyphicon-envelope"></span>
</span>
<input type="email"
class="form-control" id="email" placeholder="Enter email"
required="required" /></div>
</div>

</div>
<div class="col-md-6">
<div class="form-group">
<label for="name">
Message</label>
<textarea name="message" id="message"
class="form-control" rows="9" cols="25" required="required"
placeholder="Message"></textarea>
</div>
</div>
require("path of phpmailer folder
\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "mymail.domain.com";
$mail->SMTPAuth = true;
$mail->Username = "myemail";
$mail->Password = "psswrd";

$mail->From = "you@domain.com";
$mail->FromName = "Your Name";
$mail->AddReplyTo("you@domain.com");
$mail->AddAddress("user@domain.com");
$mail->IsHTML(true);
$mail->Subject = "Test message sent using the
PHPMailer component";
$mail->Body = "This is a test message.";
$mail->Send();
?>
<div class="col-md-12">
<button type="submit" class="btn btn-skin
pull-right" id="btnContactUs">
Send Message</button>
</div>
</div>
</form>
</div>
</div>

最佳答案

您的姓名和电子邮件输入没有列出名称属性,因此不会在表单提交中发送任何数据。

您需要按如下方式更改它们:

<input type="text" class="form-control" name="name" id="name" placeholder="Enter name" required="required" />


<input type="email" class="form-control" name="email" id="email" placeholder="Enter email" required="required" />

这可能不是导致错误的问题,但它会导致问题。

关于php - 使用 PHPmailer 从网站发送消息时遇到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35833594/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com