【发布时间】:2021-01-22 08:14:47
【问题描述】:
我正在使用 html (bootstrap4) 联系我们页面并尝试使其动态化。使用 pear mail 使用 php 测试脚本进行服务器测试。
但是当尝试进行动态调用并在电子邮件中调用归档时出现问题
任何人都可以查看下面的 php 脚本并告诉我问题出在哪里
我如何在这里调用这部分:$email_subject?电子邮件正文?和电子邮件?
<form id="contact-form" method="post" action="test.php">
<div class="row">
<!-- Name -->
<div class="col-md-6 mb-2">
<input type="text" name="Full_Name" class="form-control" placeholder="Firstname *" required="required" data-error="Firstname is required.">
</div>
<!-- Email -->
<div class="col-md-6 mb-2">
<input type="email" name="email" class="form-control" placeholder="email *" required="required" data-error="Valid email is required.">
</div>
<!-- subject -->
<div class="col-md-12 mb-2">
<input type="text" name="subject" class="form-control" placeholder="subject *" required="required" data-error="Valid subject is required.">
</div>
<!-- Message -->
<div class="col-md-12 mb-2">
<textarea name="message" class="form-control" placeholder="Message *" rows="4" required="required" data-error="Please,leave us a message."></textarea>
</div>
<!-- Submit Button -->
<div class="col-12 text-right">
<input type="submit" class=" form-control btn btn-success btn-send" value="Send message">
</div>
</div>
</form>
<!-- Email -->
<div class="col-md-6 mb-2"> <input type="email" name="email" class="form-control" placeholder="email *" required="required" data-error="Valid email is required."> </div>
<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
require_once "Mail/Mail-1.4.1/Mail.php";
$name = $_POST["Full_Name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$host = "*******"; <!--i will use my hosting server url-->
$username = "*******"; <!--i will use my email-->
$password = "*****"; <!--i will use here my email pss-->
$port = "2525";
$to = "******"; <!--i will use the email here-->
$email_from = "*****"; <!--how to call email from here by input that i defined above in php file->
$email_subject = "******" ; <!--how to call sujectl from here by input that i defined above in php file->
$email_body = "*****"; <!--how to call message from here by input that i defined above in php file->
$email_address = "*****";
$headers = array ('From' => $email, 'To' => $to, 'Subject' => $subject, 'Message' => $message, Reply-To' => $email_address);
$smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($to, $headers, $email_body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
【问题讨论】:
-
这里没有JS。删除了标签。请不要标记垃圾邮件
-
你的意思是不是:
$email_from = $email;等等?其中 $email 是您从$_POST["email"];获得的已清理地址 -
我已经定义了就像你所说的那样“$email_from = $email;”但是在提交后没有收到任何电子邮件,甚至没有收到我的联系我们页面 trun white 没有消息显示并且没有收到收件箱..但是当我使用测试脚本代替 $email_form = "xyg@gmail.com" 并且与虚拟文本相同时对于其他字段表单的工作和接收电子邮件收件箱不知道是什么问题。
-
请出示表格。也许您不发布它,或者您使用 ID 而不是 NAME
-
@mplungjan,感谢您在这里支持并尝试解决问题。我发现了错误,现在它可以工作了