0

こんにちは、データからメールとして送信しようとしています。PHP mail() を使用して電子メールを送信し、Ajax を使用してデータを送信して、ページのリロードを回避しています。フォーム送信時にメールが送信されません。私は何を間違っていますか?コードはややこのように見えます。

アヤックス:

$('#submit').click(function(){

    $.ajax({
        url: test.php,
        type:'POST',
        success: function(msg){
                alert('Email Sent');
            }                   
        });
    });

HTML フォーム:

<table width="400" border="0" cellspacing="2" cellpadding="0"> 
   <tr> 
        <td>*Your name:</td> 
        <td><input name="name" type="text" id="name" size="32"></td> 
   </tr> 
   <tr> 
        <td class="bodytext">*Email address:</td> 
        <td><input name="email" type="text" id="email" size="32"></td> 
   </tr> 
   <tr> 
        <td class="bodytext"> </td> 
        <td align="left" valign="top"><input type="submit" name="Submit" id="submit" value="Send"></td> 
   </tr> 
</table> 

php:

<?php 
if ($_POST["email"]<>'') { 
    $ToEmail = 'somugus@gmail.com'; 
    $EmailSubject = 'Fusio Dose customer info'; 
    //$mailheader = "From: ".$_POST["email"]."\r\n"; 
    //$mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    //$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"]."\r\n"; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."\r\n"; 
    $MESSAGE_BODY .= "Primary: ".$_POST["primary"]."\r\n";
    $MESSAGE_BODY .= "Sedcondary: ".$_POST["secondary"]."\r\n";
    //$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 

作業例はこちら

http://soumghosh.com/otherProjects/Kemail/emailTest1.html

4

3 に答える 3