php - 将表格详细信息发送到电子邮件

标签 php html css email

我创建了一个表单和 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/

相关文章:

php - 基于 CSS :root variables 动态生成 add_theme_support( 'editor-color-palette') 颜色

php - Laravel 5.5 中 stdClass 类的对象无法转换为字符串

html - 我怎么知道用户何时取消 HTML5 地理定位?

javascript - 在 Canvas 上绘图时出现 HTML 错误

javascript - 获取网页标题和段落

php - 如何使用 PHP 编辑外部 css 文件?

PHP XPath。如何返回带有html标签的字符串?

html - CSS悬停div1.img1影响另一个div2.img2

php - HTML - 换行符被解释为空白字符

css - 在 div 外显示 Bootstrap 弹出窗口,溢出 :hidden