在静态网站中使用PHP联系表单

Contact form with PHP in static website

本文关键字:PHP 联系 表单 静态 网站      更新时间:2023-09-26

我终于完成了我的网站,唯一剩下的就是联系表单了。这是一个静态网站,我想知道是否有任何解决方案的功能联系形式。我已经尝试了Formspree,它工作得很好,但我想如果可能的话,一种方式直接从我的网站发送电子邮件,而不使用第三方服务。这是html表单

<form role="form" class="contact-form" method="post" action="php/contact.php" name="contact_form">
<div class="wow fadeInLeft" data-wow-delay=".5s">
<div class="form-group">
<div class="controls">
<input type="text" class="form-control" placeholder="Name" name="name">
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="email" class="form-control email" placeholder="eMail" name="email">
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="text" class="form-control requiredField" placeholder="Subject" name="subject">
</div>
</div>
<div class="form-group">
<div class="controls">
<textarea rows="4" class="form-control" placeholder="Type a message here" name="message"></textarea>
</div>
<button type="submit" id="submit" class="btn btn-lg btn-common">SEND</button>
</div>
</div>
</form>

Css和javascript默认为bootstrap。电子邮件域名是info@mywebsite.com,所以没有gmail或其他东西。

我的action.php(不工作)是我在这里找到的:http://bootstrapious.com/p/how-to-build-a-working-bootstrap-contact-form

如果你不能在你的服务器上运行PHP脚本,它显然不会工作。你需要一个支持PHP的网站主机

如果您使用第三方电子邮件服务,我一直发现最好使用PHPMailer,它提供了完整的工具,可以连接到几乎任何SMTP服务器(包括Google邮件)。

这里有很多例子可以让你开始和运行。

如果,正如其他用户所说,您的web服务器没有启用PHP,那么显然这将无法工作-考虑提供更多的信息,究竟是什么不能与您的示例脚本。