-2

送信後にメールが届かないことを除いて、すべてが機能し、なぜだろうか?

このエラーが発生し続けます「メール配信プログラム '/usr/local/bin/sendmail -oi -t' を実行できませんでした」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 に答える