我创建了这个联系表单,当你点击发送它时会带你到一个感谢屏幕,但我不知道怎么把它发送到我的电子邮件地址。如果有人可以帮助我,我会很感激。
ContactUs html file
<form action="mail.php" method="post">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Priority</p>
<select name="priority" size="1">
<option value="Low">Low</option>
<option value="Normal">Normal</option>
<option value="High">High</option>
</select>
<br />
<p>Type</p>
<select name="type" size="1">
<option value="update">Question</option>
<option value="change">Information Change</option>
<option value="addition">Information Addition</option>
<option value="new">Misc.</option>
</select>
<br />
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" name="sendemail" value="Send"><input type="reset" value="Clear">
</form>
邮件php文件
<?php
if(isset($_POST["sendemail"]))
{
$name = $_POST['name'];
$email = $_POST['email'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Priority: $priority \n Type: $type \n Message: $message";
$recipient = "dnasim09@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='form.html' style='text- decoration:none;color:#ff0099;'> Go Somewhere you are already home ;)</a>";
}
?>
答案 0 :(得分:0)
试试这个https://github.com/PHPMailer/PHPMailer
你可以配置一个smtp来发送电子邮件,我猜你的代码问题是你的服务器没有任何电子邮件发送方法,你需要一个smtp来发送电子邮件