浏览器加载我的PHP文件而不是发送电子邮件

时间:2017-10-28 14:41:54

标签: php email

我希望表单将内容发送到我的电子邮件,而不是只是在新窗口中显示我的PHP代码,任何人都可以帮忙吗?这是代码:

索引

<form action="send.php" method="POST">
  Name: <br><input type="text" name="name"><br><p>
  Request: <br><textarea name="request"></textarea><p>
  <input type="submit" name="submit" value="Send!">
</form>

PHP:

<?php
$name = $_POST['name'];
$request = $_POST['request'];

$to = "myemail@email.co.uk";
$subject = "It's just a test";
$body = "This is just a test to see if things are working okay \n\n $request";

mail ($to,$subject,$body);

echo "Message sent!"
?>

1 个答案:

答案 0 :(得分:0)

初学者的一些提示

  1. 首先配置您的Xampp表单发送电子邮件How to configure XAMPP to send mail from localhost?
  2. 检查数据是否来自print_r($_POST)
  3. 发送给send.php
  4. 请按照本教程发送电子邮件from here