如何配置WAMP和Smtp服务器

时间:2014-01-28 12:04:32

标签: forms smtp wamp contact configure

我花了很长时间寻找答案,并尝试了所有解决方案但没有成功:/

基本上我想使用wamp服务器来创建将发送到我的邮件地址的联系表单。

我已经运行了但是对于我的生活我无法弄清楚为什么我不会收到邮件,我在提交表单时得到404页面,或者最近“警告:邮件():SMTP服务器回复:553抱歉,该域名不在我允许的rcpthosts列表中。“

我现在正在寻找一种解决方案,至少将表单发送到我的地址,无论是否安全我只是想看到成功发送的实际邮件。

谢谢!

编辑:这是代码:

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"                          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
<title> Contact Form</title>

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

<link rel="stylesheet" type="text/css" href="style.css" />
    </head>

    <body>

<div id="page-wrap">



    <div id="contact-area">

        <form method="post" action="contactengine.php">
            <label for="Name">Name:</label>
            <input type="text" name="Name" id="Name" />


            <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 style="clear: both;"></div>



    </div>

</div>

    </body>

    </html>


    --then the contact engine--

    <?php

    $EmailFrom = "myadress@mail.com";
    $EmailTo = "myadress@mail.com";
    $Subject = "Nice & Simple Contact Form by CSS-Tricks";
    $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 .= "\n";
    $Body .= "Tel: ";
    $Body .= $Tel;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $Email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $Message;
    $Body .= "\n";

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

    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>

    --then the thanks message--
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">

    <head>
        <title>A Nice & Simple Contact Form</title>

        <link rel="stylesheet" type="text/css" href="style.css" />
    </head>

    <body>

        <div id="page-wrap">

            <img src="images/title.gif" alt="A Nice & Simple Contact Form" />
            <p>By <a href="http://css-tricks.com">CSS-Tricks</a></p>


            <br /><br />


            <h1>Your message has been sent!</h1><br />

    <p><a href="index.html">Back to Contact Form</a></p>

        </div>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-68528-29";
urchinTracker();
</script>

    </body>

    </html>

1 个答案:

答案 0 :(得分:0)

Windows没有邮件服务器,所以只要调用mail()就可以使用php,但邮件无处可去。

您需要安装邮件服务器或使用类似PHPMailer库的内容,以允许您通过Yahoo或Google等方式发送SMTP邮件。