我创建了一个表单和 php 以将表单详细信息发送到我的电子邮件。但是当通过本地主机通过 wampserver 运行网页时,它显示错误为“警告:邮件():无法在“本地主机”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用C:\wamp\www\My original web\PHP\ContactUs.php 第 22 行中的 ini_set()"。我找不到第 22 行的错误位置。
<div class="container">
<form name="htmlform" method="POST" action="../PHP/ContactUs.php">
<label for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Your Name">
<label for="email">Email Address</label>
<input type="text" id="email" name="email" placeholder="Your Email Address">
<label for="phone">Phone Number</label>
<input type="text" id="phone" name="phone" placeholder="Your Phone Number">
<label for="Message">Message</label>
<textarea id="message" name="message" placeholder="Write You Something" style="height:200px"></textarea>
<input type="submit" value="Submit">
</form>
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "pinkmaidbeautysalon@gmail.com";
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$message = $_REQUEST['message'];
//send email
mail($admin_email, "$name", "$phone", "$message", "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<?php
}
?>
最佳答案
最好的选择是使用 PHPmailer这将使您能够正确发送邮件并节省大量时间。
How To Use PHPMailer本教程将为您提供指导。
关于php - 将表格详细信息发送到电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44213631/