dourong9253 2013-09-04 18:21
浏览 98

Html / php电子邮件页面/表单

I want to use php and HTML to create a contact page so users can send me an message directly from the website to my email-account

The only problem I have is that, it doesn't send any messages to my email-inbox(no errors on page)

Here is the code:

HTML(no css style): INDEX.html

<!DOCTYPE html >
<html>

<head>
    <title>Contact US</title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


</head>

<body>

    <div id="page-wrap">



        <div id="contact-area">
            SEND US A MESSAGE:
            <form method="post" action="contactengine.php">
                <label for="Name">Name:</label>
                <input type="text" name="Name" id="Name" />

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

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

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

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

        </div>

    </div>

</body>

</html>

PHP: contactengine.php

<?php

$EmailFrom = "JhonDoe@domain.com";<-- not sure about this one
$EmailTo = "MyEmail@domain.com";
$Subject = "WebSite Message";
$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "
";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "
";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "
";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "
";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");


?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程