0

我希望我的表单向我发送一封电子邮件,但我不确定在哪里/如何对 html 进行编码,以便表单中的所有字段都填充电子邮件。或者,这真的应该转到服务器端的页面吗?

这是我现有的代码。你能告诉我如何解决吗?

 <!-- Contact Section -->
  <div class="section contact" id="contact">
    Contact
    <h2>Say hello</h2>
    <p>Whether you have a communication need to be fully developed, or a quick question for a no-charge opinion or assesment, share the goods here.</p>

    <form action="sendEmail.php" method="POST" class="myForm clearfix" autocomplate="off"> 


      <div class="form-field">

        <label for="name">Name</label>
        <input type="text" id="name">

      </div>

      <div class="form-field">

        <label for="issue">Describe your issue or opportunity </label>
        <textarea name="issue" cols="30" rows="10"></textarea>

      </div>

      <div class="form-field">

      <label for="file">Attach a file</label>
      <input type="file" id="file">

      </div>

      <div class="form-field">

      <label for="email">Email</label>
     <!--  <input type="text" id="email"> -->
      <input type="email" name="emailAddress" placeholder="Please enter your email address">

    </div>

    <div class="form-field">

      <label for="phone">Phone </label>
      <input type="text" id="phone">

    </div>

    <div class="form-field">


      I prefer to be contacted by:
      Email <input type="radio" name="contact" value="email">
      Phone <input type="radio" name="contact" value="phone">

      <!-- <form method="post" action="mailto:info@whatshouldisay.ca" >
<input type="submit" value="Submit form" />  -->

<input type="submit" value="Submit"  -->

    </div>


    </form>


  </div>
4

1 回答 1

4

如果你想使用mailto:,它只是打开用户的电子邮件客户端并预先填写了字段,你不使用 POST 表单,你使用 GET 表单。

<form action="mailto:test@example.com">
    Subject: <input name="subject"><br>
    Body: <input name="body"><br>    
    <input type="submit">
</form>

为我工作。


如果您想直接从您的服务器发送电子邮件(完全绕过用户的电子邮件客户端),您需要设置一个脚本来处理表单发布。

于 2013-08-14T19:47:54.447 回答