0

收不到邮件。这让我发疯了,原来的问题,以前只有这个领域。电子邮件、主题、消息。我收到了电子邮件,但我看不到电子邮件变量。它刚从我的服务器进来。所以我无法回复我收到的任何电子邮件。想添加另一个字段。“再次发送电子邮件”,但它说它正在发送电子邮件,而我的收件箱中什么也没收到。这里有什么问题?(注意:出于安全原因,emailfield 已删除)

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>testing</title>
<style type="text/css">
body,td,th {
    color: #F7F3F3;
}
body {
    background-color: #050505;
}
</style>
</head>
<body style="text-align: center">
<?php ?>
<br />
<?php 
if (isset($_POST['submit'])){
{
    //excute the code
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $eg = $_POST['eg'];
    $message = $_POST['message'];

    if (strlen($email) <= 0)
        {
        echo "You need to enter an email";
    }else{
        if (strlen($subject) <= 0)
            {echo "You need to enter a subject";
        }else{
                        if (strlen($message) <= 0)
                    {echo "You need to enter a message";
            }else{
                            if (strlen($eg) <= 0)
                        {echo "Email Again";
                }else{
                    if(filter_var($email, FILTER_VALIDATE_EMAIL) == true){
                    //continue with code
                    mail("random@gmail.com", $subject, $message, $eg,  "From:$email");
                    echo "Your message has been sent";
                    }
                        else
                            {
                        echo "You must fill out the entire form";
                            }
                     }
                }
            }
}
}
}
?>
<br />
<span style="text-align: center">This is the contact form.</span>
<form method="post" action="testing.php">
  <table align="center" style="color: #030303;">
<tr><td>Email: <input type="text" name="email" /></td></tr>
<trd><td>Email Again:<input type="text" name="eg" /></td></tr>
<trd><td>Subject:<input type="text" name="subject" /></td></tr>
<trd><td><label for="textarea">Message:</label>
<textarea name="message" cols="40" rows="15">Type your message here.</textarea></tr><tr>
  <trd><td><input type="submit" name="submit" value="send" /></td></tr>
</table>
</form>
4

2 回答 2

0

您将一个帖子字段$_POST['eg']作为邮件标题传递。这总是会导致某种问题。

mail("random@gmail.com", $subject, $message, $eg,  "From:$email");

应该

mail("random@gmail.com", $subject, $message, "From:$email");

删除该$eg参数。第 4 个位置是标题字符串。5th 可以是附加参数,但我认为您可能想了解这实际上意味着什么。请参阅此处的文档:

http://php.net/manual/en/function.mail.php

更新:

$header = "Reply-To: username@webhosting400.myserver.net\r\n"; 
$header.= "MIME-Version: 1.0\r\n"; 
$header.= "Content-Type: text/plain; charset=utf-8\r\n"; 
$header.= "X-Priority: 1\r\n"; 

mail("random@gmail.com", $subject, $message, $header);
于 2013-09-27T17:38:17.620 回答
0

更正您的<tr>标签,这可能会导致问题

<trd><td>Email Again:<input type="text" name="eg" /></td></tr>
   ^
<trd><td>Subject:<input type="text" name="subject" /></td></tr>
   ^
<trd><td><label for="textarea">Message:</label>
   ^
<textarea name="message" cols="40" rows="15">Type your message here.</textarea></tr><tr>
  <trd><td><input type="submit" name="submit" value="send" /></td></tr>
     ^

正确的方法是

<tr><td>Email Again:<input type="text" name="eg" /></td></tr>
<tr><td>Subject:<input type="text" name="subject" /></td></tr>
<tr><td><label for="textarea">Message:</label>
<textarea name="message" cols="40" rows="15">Type your message here.</textarea></tr><tr>
  <tr><td><input type="submit" name="submit" value="send" /></td></tr>
于 2013-09-27T17:34:50.110 回答