0

我想知道是否有人能看到我在这里做错了什么。我的 html 看起来像这样

<form action="process.php" method="post">
    <fieldset>
        <div id="inputLeft">
            <p>
                <label for="name">Full Name</label>
                <input class="validate[required,custom[onlyLetter],length[0,100]]" name="name" type="text" id="name" value="">
            </p>
            <p>
                <label for="email">Email Address</label>
                <input class="validate[required,custom[email],length[0,100]]" name="email" type="text" id="email" value="">
            </p>
            <p>
                <label for="subject">Subject</label>
                <input class="validate[required,length[5,600]" name="subject" type="text" id="subject" value="">
            </p>
        </div>
        <div id="inputRight">
            <p>
                <label for="country">Country</label>
                <input name="country" type="text" id="country" value="">
            </p>
            <p>
                <label for="phone">Phone Number</label>
                <input name="Phone" type="text" id="phone" value="">
            </p>
            <p>
                <label for="url">Website</label>
                <input name="url" type="text" id="url" value="">
            </p>
        </div>
        <p>
            <label for="message">Message</label>
        <textarea name="message" cols="120" rows="8" id="message"></textarea>
        </p>
    </fieldset>

和这样的php

<?php
   # recipient
   $recipient = 'sean@seankonig.co.za'

   # subject
   $subject = $_Post['subject'];

   # headers
   $headers = "Website enquiry <>\r\n";

   # message
   $message =  "Name : {$_POST['name']}\n";
   $message .= "Email : {$_POST['email']}\n";
   $message .= "Subject : {$_POST['subject']}\n";
   $message .= "Message : {$_POST['message']}\n";

   if( mail($recipient, $subject, $message, $headers) ) echo "Mail Sent";
   else echo "Mail Could Not Be Send";
?>

测试时它说邮件已发送,但没有发送。你能看看,让我知道吗?

4

2 回答 2

0

您还可以扩展您的headers. 这不一定会影响您的内容,但会影响您的邮件是否进入垃圾邮件箱:

$headers = 'MIME-Version: 1.0' . PHP_EOL;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
$headers .= "FROM: Website.com <noreply@website.com>" . PHP_EOL;
$headers .= "Return-Path: noreply@website.com" . PHP_EOL;
$headers .= "Reply-To: noreply@website.com" . PHP_EOL;

请注意,它PHP_EOL也可以写成\r\n,但我的脚本PHP_EOL效果更好(标题在发送的邮件中显示为内容)。

于 2013-06-04T10:20:19.977 回答
0

通过快速查看您的代码,我发现了一些可能导致电子邮件无法正常工作的错误

$recipient = 'sean@seankonig.co.za'; //you are missing a semicolon here

$subject = $_Post['subject'];//$_POST is not the same as $_Post
于 2013-06-04T10:13:21.237 回答