将表格详情发送至电邮

时间:2017-05-27 06:17:23

标签: php html css email

我创建了一个表单和php,将表单详细信息发送到我的电子邮件。但是当通过wampserver通过localhost运行网页时,它会显示错误“警告:mail():无法连接到”localhost“端口25的邮件服务器,验证php.ini中的”SMTP“和”smtp_port“设置或使用ini_set()在C:\ wamp \ www \我的原始web \ PHP \ ContactUs.php第22行“。我找不到第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
  }
?>

2 个答案:

答案 0 :(得分:0)

最适合您的选择是使用PHPmailer,这样您就可以正确发送邮件并节省大量时间。
How To Use PHPMailer本教程将指导您。

答案 1 :(得分:0)

你应该使用标题。您可以使用任何第三方服务器测试工具来测试localhost中的邮件。例如: - &#34;测试邮件服务器工具&#34;

public class DeviceConfigurationController {

    @FXML private ListView<DeviceConfiguration> device_list;
    @FXML
    private void initialize() {
        device_list.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
            UndoManager.add(new ListViewSelectionChange<>(oldValue, device_list));
        });
    }

    //redo/undo stuff
    @FXML
    private void undo() {
        UndoManager.undo(); //calls the last Change
    }
}

public class ListViewSelectionChange<T> implements Change {

    privateT lastValue;
    private T redoValue;
    ListView<T> listView;

    public ListViewSelectionChange(T lastValue, ListView<T> listView) {
        this.lastValue = lastValue;
        this.listView = listView;
    }

//gets called from the undomanager
    @Override
    public void undo() {
        redoValue = listView.getSelectionModel().getSelectedItem();
        listView.getSelectionModel().select(lastValue); //fires the selection listener again, thus adding a ListViewSelection to the UndoManager
    }
}