-2

所以一切正常,除了我在发送后没有收到电子邮件并想知道为什么?

不断收到此错误“无法执行邮件传递程序'/usr/local/bin/sendmail -oi -t' in”Html

<form action="process.php" method="post">
<ul>
<li>
    <label for="name">Name:</label>
    <input type="text" name="name" id="name" />
</li>
    <li>
    <label for="email">Email:</label>
    <input type="text" name="email" id="email" />
</li>
<li>
<label for="topic">Topic:</label>
<select>
    <option value="optiona">optiona</option>
    <option value="optionb">optionb</option>
    <option value="optionc">optionc</option>
</select>
</li>
<li>
<label for="message">your message:</label>
<textarea id="message" name="message" cols="42" rows="9"></textarea>
</li>
<li><input type="submit" value="Submit"></li>
</form>

PHP

<?php
$to = 'robin.kahrle@gmail.com';
$subject='hi there you';
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$message = <<<EMAIL
Hi! My name is $name.
$message
From $name
my email is $email
EMAIL;

$header ='$email';
if($_POST){
mail($to, $subjects, $message, $header);
$feedback = 'Thankyou for your email';
echo $feedback;
 }

 ?>
4

1 回答 1

0

也许您的$header$message定义不正确。尝试这个:

<?php
    // Constants
    $to = 'robin.kahrle@gmail.com';
    $subject='hi there you';

    // Variable contents from the form
    $name =    (!empty($_POST['email'])) ? $_POST['name'] : '????';
    $email =   (!empty($_POST['email'])) ? $_POST['email'] : $to;
    $message = 'Hi? my name is ' . $name;
    if (!empty($_POST['message'])) $message .= . "\r\n" . $_POST['message'];

    // Header
    $header = 'From: ' . $email . "\r\n" .
              'Reply-To: webmaster@example.com' . "\r\n" .
              'X-Mailer: PHP/' . phpversion();

    // Send mail and give feedback
    $accepted = mail($to, $subjects, $message, $header);
    if ($accepted) {
        $feedback = 'Thankyou for your email';
    } else {
        $feedback = 'Email not accepted';
    }
    echo $feedback;
于 2016-02-15T15:15:13.073 回答