我下载了php邮件程序,并使用以下编码添加Contactformhandler.php文件。但是我网站上的留言服务效果不佳。请帮帮我。
我收到错误 - (!)致命错误:第4行的C:\ wamp \ www \ carlmckever.com \ ContactFormHandler.php中找不到类'PHPMailer' 调用堆栈
1 0.0008 247024 {main}().. \ ContactFormHandler.php:0
Contactformhandler.php编码是 -
<?php
require("mails\phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Port = "587";
$mail->SMTPAuth = true;
$mail->SMTPDebug = 2;
$mail->Username = "sahil.katia7@gmail.com";
$mail->Password = "password";
$mail->From = "sahil.katia7@gmail.com";
$mail->FromName = "admin";
$mail->AddReplyTo("sahil.katia7@gmail.com");
$mail->AddAddress("sahil.katia7@gmail.com");
$mail->IsHTML(true);
$mail->Subject = "Test message sent using the PHPMailer component";
$mail->Body = "This is a test message.";
if(!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent successfully"; }
header('location:index.html');
?>
Htmlcontactformcoding -
<!---ContactFormSection-->
<div class="row">
<div class="col-lg-8">
<div class="boxed-grey">
<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>
<div class="col-md-12">
<button type="submit" class="btn btn-skin pull-right" id="btnContactUs">
Send Message</button>
</div>
</div>
</form>
</div>
</div>
答案 0 :(得分:0)
PHP无法理解Windows路径:
require("mails\phpmailer.php");
^---
这只是一个转义p
,这对PHP没什么意义,所以你有效地做了
require("mailsphpmailer.php");
你被告知,正确,不存在。
尝试
require("mails/phpmailer.php");
代替。请注意/
...