0
用戶這是我的HTML表單發送確認電子郵件給誰填表格
<form method="post" name="myemailform" action="form-to-email.php">
<p>
<label for='name'>Enter Name: </label><br>
<input type="text" name="name">
</p>
<p>
<label for='email'>Enter Email Address:</label><br>
<input type="text" name="email">
</p>
<p>
<label for='message'>Enter Message:</label> <br>
<textarea name="message"></textarea>
</p>
<input type="submit" name='submit' value="submit">
</form>
這是PHP的郵件代碼拿過數據時,用戶點擊提交
<?php
if(!isset($_POST['submit']))
{
echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
//Validate first
if(empty($name)||empty($visitor_email))
{
echo "Name and email are mandatory!";
exit;
}
$email_from = '[email protected]';//<== update the email address
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message".
$to = "[email protected]";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thank-you.html');
?>
這表明沒有錯誤但只是在網頁上降落thank-you.html我檢查了我的電子郵件帳戶但沒有收到郵件
請幫忙什麼錯了
@戴爾thanx,但沒有 – Bandayar
有趣的是,正是我想到當我看到你的問題! – Dale
當然,在表單提交後(註冊表格會有很多例子),必須有很多通過php發送郵件的教程。只要用谷歌搜索就足夠了。 –