<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "[email protected]";
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$comment = $_REQUEST['comment'];
//send email
mail($admin_email, "$subject", $comment, "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<form method="post">
<input name="email" type="text" class="form-control" placeholder="Enter your email address...">
<input name="subject" type="text" class="form-control" placeholder="Subject">
<br>
<textarea name="comment" class="form-control" rows="3"></textarea>
<br>
<div class="mesbutts">
<button type="submit" class="btn btn-primary" value="Submit">Send</button>
<button type="reset" value="Reset" class="btn btn-default" >Clear</button>
</div>
</form>
<?php
}
?>
嗨,大家好,我似乎無法弄清楚如何讓我的PHP代碼在通過使用表單發送電子郵件時工作。我已經把我的個人電子郵件,我似乎無法收到他們。你能幫我看看我的語法錯誤嗎?通過PHP中的表單類型html發送電子郵件
謝謝你隊友!
您需要使用頭的功能,郵件和設置'內容type'手動http://php.net/manual/en/function.mail.php的 – Naumov
可能的複製鎖定例如4號給你任務[PHP的郵件表單不完整發送電子郵件](http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-email) – Qirel
嗨@Naumov你怎麼可以去做?對不起,我在PHP –