0

php で登録用のフォームを作成しました。フォームには送信者の電子メール アドレス フィールドがあります。送信者のメール アドレスは、送信者のメール アドレス フィールドから取得されます。管理者のメール アドレスは固定です。送信者ヘッダーの場合 = "from : no-reply@eschool.com" messagebody はそのまま

admin headers=" from :$email" messagebody の場合はそのまま

私はこれをやろうとしました:

HTML コード:

<form action="action.php" method="post">
    <table>
        <tr>
            <td>Name</td>
            <td>:</td>
            <td><input type="text" name="name" width="400" /></td>
        </tr>
        <tr>
            <td>Address</td>
            <td>:</td>
            <td><input type="text" name="address" width="400" /></td>
        </tr>
        <tr>
            <td>Email</td>
            <td>:</td>
            <td><input type="text" name="email" width="400" /></td>
        </tr>
        <tr>
            <td>Password</td>
            <td rowspan="2">&nbsp;</td>
            <td>
                <p><input type="text" name="pass" width="400" /></p>
                <p>&nbsp;</p>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="insert" value="Insert" /></td>
        </tr>
    </table>

    <input type="submit" value="submit" />
</form>

action.php

$name    = $_POST["name"];
$address = $_POST["address"];
$email   = $_POST["email"];

$password = $_POST['pass'];
$subject  = "Thank you for your registration.";
$admin    = "info@editor.com";

$to = $email . "," . $admin;

$email_message .= "Name: ". $name."\n";
$email_message .= "Address: ".$address."\n";
$email_message .= "Email: ".$email."\n";
$email_message .= "password: ".$password."\n";

$headers  = "MIME-Version: 1.0" . "\n";
$headers .= "Content-type:text/plain;charset=UTF-8;" . "\n";
$headers .= "content-Transfer-encoding: 8bit" ."\n";
$headers .= "From: no-reply@eschool.com ". "\n";

mail($to, $subject, $email_message, $headers);

ありがとう

4

2 に答える 2

1

あなたのコードは完璧です、あなたが直面している問題は何ですか、あなたの問題を書いてください. 便宜上、action.php に次の変更を加えます。

<?php
   $name    = $_POST["name"];
   $address = $_POST["address"];
   $email   = $_POST["email"];
   $password = $_POST['pass'];
   $subject  = "Thank you for your registration.";
   $admin    = "info@editor.com";
   //$to = $email  $admin;
   $email_message = '';

   $email_message .= "Name: ". $name."\n";

   $email_message .= "Address: ".$address."\n";

   $email_message .= "Email: ".$email."\n";

   $email_message .= "password: ".$password."\n";


   $headers1  = 'MIME-Version: 1.0' . "\r\n";
   $headers1 .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";   
   $headers1 .= "From: no-reply@eschool.com ". "\n";

   $headers2  = 'MIME-Version: 1.0' . "\r\n";
   $headers2 .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";   
   $headers2 .= "From: ". $email . "\n"; 

   if(@mail( $email, $subject, $email_message  , $headers1 )) {
     @mail( $admin, $subject, $email_message  , $headers2 )          
    echo "Mail Sent.";
   } else {
    echo "Mail Not Sent.";
   }
?>   
于 2013-05-08T05:05:55.203 に答える
0

mail(...)ヘッダーの 2 つの異なるバージョンを作成し、 2 回実行するだけです。

<?php

    $name    = $_POST["name"];
    $address = $_POST["address"];
    $email   = $_POST["email"];

    $password = $_POST['pass'];
    $subject  = "Thank you for your registration.";
    $admin    = "info@editor.com";


    $email_message = "Name: ".$name."\n";
    $email_message .= "Address: ".$address."\n";
    $email_message .= "Email: ".$email."\n";
    $email_message .= "password: ".$password."\n";

    $headers  = "MIME-Version: 1.0\n";
    $headers .= "Content-type:text/plain;charset=UTF-8;\n";
    $headers .= "content-Transfer-encoding: 8bit\n";

    $poster_headers = $headers . "From: no-reply@eschool.com\n";
    $admin_headers = $headers . "From: ".$email."\n";

    mail( $admin, $subject, $email_message, $admin_headers );
    mail( $email, $subject, $email_message, $poster_headers );
?>
于 2013-05-08T05:03:15.477 に答える