我正在一个网站上工作,该网站有一个简单的联系表格,网站访问者可以在其中输入他的姓名,电子邮件地址和他的消息,所有这些数据都将被发送到目的地电子邮件,我试过几个解决方案,但我无法在目的地电子邮件中找到结果。
PS:我使用EasyPhp启动并运行HTTP SERVER
HTML来源
<form method="post" action="C:\Users\myPC\Desktop\WEBSITE\root\assets\php\contact.php">
<div>
<label for="name">Name: </label>
<input type="text" id="name" name="name">
</div>
<div>
<label for="email">Email: </label>
<input type="email" id="email" name="email">
</div>
<div>
<label for="message">Message: </label>
<textarea id="message" name="message" rows="4"></textarea>
</div>
<button type="submit" name="send">Submit</button>
</form>
PHP SOURCE
<?php
$name = $_POST['name']; //user input name
$email = $_POST['email']; //user input email
$message = $_POST['message']; //user input message
$secured_name = htmlspecialchars($name);
$secured_email = htmlspecialchars($email);
$secured_message; = htmlspecialchars($message);
$formcontent="From: $secured_name \n Message: $secured_message"; //E-mail body (username + e-mail message)
$recipient = "myservice@outlook.com"; //support service EMAIL
$subject = "Contact request - website"; //E-mail subject
$mailheader = "From: $secured_email \r\n"; //sender E-mail
//action
if (isset($_POST["send"])) {
mail($recipient, $subject, $formcontent, $mailheader)
or die("Error!");
}
?>