我没有使用任何PHP,并想使我的html文件的形式发送一封电子邮件,而无需使用的mailto:通过PHP发送电子邮件?
我在网上找了如何做一些这方面的教程,和最好的我可以做我自己是这个。
<form method="POST" action="contact.php">
<input type="text" name="FirstName" placeholder="First Name" size="24px"/> <input type="text" name="LastName" placeholder="Last Name" size="24px"/><br>
<input type="tel" name="Phone" placeholder="Address" size="53px"/><br>
<input type="text" name="Address" placeholder="Phone Number" size="53px"/><br>
<input type="email" name="email" placeholder="Email Address" size="53px"/><br>
<input type="email" name="confirmemail" placeholder="Confirm Email" size="53px"/><br>
<input type="submit" name="submitButton" />
</form>
和我的PHP文件中的最好的,我可以尝试得到的是:
<?php
if($_POST["submit"]) {
$recipient="[email protected]";
$subject="Form to email message";
$sender=$_POST["Email sender"];
$senderEmail=$_POST["[email protected]"];
$message=$_POST["This is my message"];
$mailBody="Name: $sender\nEmail: $senderEmail\n\n$message";
mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");
$thankYou="<p>Thank you! Your message has been sent.</p>";
}
?>
当我点击我的提交按钮,我得到的是这样的:
如果你们中的任何人都可以帮我解决这个问题,那么我将非常感谢。
谢谢
您使用的是网络服务器?您需要一台服务器来运行PHP脚本。 – Barmar
你必须使用网络服务器吗?我只在本地运行它。 – grmackintosh
grmackintosh - 是的。下载并安装[WAMP](http://www.wampserver.com/en/)在您的Windows计算机上进行PHP开发。然后回来编辑您的问题,并在运行代码时产生任何错误。 –