-2

我有一个简单的 HTML 表单,需要发布到外部电子邮件:vynora2011@hotmail.com,如下所示:

<form method="post" action="mailto:vynora2011@hotmail.com" ENCTYPE="text/plain">
                <label for="Name">Naam:</label>
                <input type="text" name="Name" id="Name" />

                <label for="City">Plaats:</label>
                <input type="text" name="City" id="City"  />

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

                <label for="Message">Bericht:</label>
                <textarea name="Message" rows="5" cols="20" id="Message"></textarea>

            <input type="submit" name="submit" value="Bericht verzenden" class="submit-button" />
            </form>

示例:JsFiddle

当我检查我的电子邮件时,我看不到任何消息。

4

1 回答 1

1

你应该有一些 PHP(或其他语言)。因为我心情不错,所以我会为你做的。只需复制/粘贴此代码:

  <?php 
if ($_POST["email"]<>'') { 
    $ToEmail = 'vynora2011@hotmail.com'; 
    $EmailSubject = 'Mail Subject'; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"].""; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."";
    $MESSAGE_BODY = "City: ".$_POST["city"].""; 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["message"]).""; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?>
    Your message has been send. 
    <?php 
} else { 
?>
    <form id="contato-main" action="index.php" method="post">
      <input id="name" name="name" type="text" required="required" placeholder="Naam"/>
      <input id="email" name="email" type="text" required="required" placeholder="E-Mail" />
      <input id="city" name="city" type="text" placeholder="Plaats"/>
      <textarea id="message" name="message" required="required" placeholder="Bericht></textarea>
      <br />
      <input id="submit" type="submit" name="Submit" value="Submit" />
    </form>
    <?php 
}; 
?>

当然,编辑以适应您的(css)需求。此外,将“$EmailSubject = '' 中的邮件主题编辑为您想要的内容。

于 2013-01-16T12:27:57.860 回答