-2

2 つのコードがあり、メール フォームからメールを送信できません。sendmail.php ファイルが見つからないと思います。これを書いたり、スクリプトを使用して使用できるようにするのを手伝ってくれる人はいますか? 私が持っているコードはです。

  var name = jQuery("input#name").val();
    if (name == "") {
  jQuery("span#name_error").show();
  jQuery("input#name").focus();
  return false;
}
  var email = jQuery("input#email").val();
  if (email == "") {
  jQuery("span#email_error").show();
  jQuery("input#email").focus();
  return false;
}

var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test(email)) {
jQuery("span#email_error2").show();
jQuery("input#email").focus();
  return false;
}

var subject = jQuery("input#subject").val();

  var msg = jQuery("textarea#msg").val();
  if (msg == "") {
  jQuery("span#msg_error").show();
  jQuery("textarea#msg").focus();
  return false;
}

    var dataString = 'name='+ name + '&email=' + email + '&subject=' + subject + '&msg=' + msg;
    //alert (dataString);return false;

  jQuery.ajax({
  type: "POST",
  url: "sendemail.php",
  data: dataString,
  success: function() {
    jQuery('#contactform').html("<div id='message'></div>");
    jQuery('#message').html("<strong>Contact Form Submitted!</strong>")
    .append("<p>We will be in touch soon.</p>")
    .hide()
    .fadeIn(1500, function() {
      jQuery('#message');
    });
  }
 });
return false;
});

});'

<div id="contactform">
                              <form id="contact" action="#">
                                  <fieldset>
                                      <span class="error" id="name_error">Please enter name !</span>
                                      <span class="error" id="email_error">Please enter email address !</span>
                                      <span class="error" id="email_error2">Please enter valid email address !</span>
                                      <span class="error" id="msg_error">Please enter message !</span>
                                      <label for="name" id="name_label">Your Name (required)</label>
                                      <input type="text" name="name" id="name" size="50" value="" class="text-input" />
                                      <label for="email" id="email_label">Your Email (required)</label>
                                      <input type="text" name="email" id="email" size="50" value="" class="text-input" />
                                      <label for="subject" id="subject_label">Subject</label>
                                      <input type="text" name="subject" id="subject" size="50"  value="" class="text-input" />
                                      <label for="msg" id="msg_label">Your Message (required)</label>
                                      <textarea rows="8" name="msg" id="msg" class="text-input"></textarea>
                                      <br />
                                      <input type="submit" name="submit" class="button" id="submit_btn" value="Send"/>
                                  </fieldset>
                              </form>
                        </div><!-- end contactform --> 

助けてください。

4

2 に答える 2

0

Use the below code to send e-mail from your from

<?php
if(isset($_POST['submit']))
{
    $to = "someone@example.com"; // Replace This Id With Another ( Where U Need to Send )
    $subject = $_POST['subject']; // Enter A Subject..
    $message = 'Name : '.$_POST['name'].'<br/> Email : '.$_POST['email'].'<br/> Subject : '.$_POST['subject'].'<br/> Message : '.$_POST['msg'].' ';
    $from = $_POST['email'];
    $headers = "From:" . $from;
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
}
?> 

* You Need To Replace $to value with your value for * For eg if you need to send the mail to abc@va.com use this $to = "abc@va.com";

于 2013-01-10T06:30:33.903 に答える
0

次の例を試してみてください。

sendmail.php

<?php
$uname     =   mysql_real_escape_string($_POST['name']);
$uemail    =   mysql_real_escape_string($_POST['email']);
$usubject  =   mysql_real_escape_string($_POST['subject']);
$umsg      =   mysql_real_escape_string($_POST['msg']);
$to = 'john@gmail.com'; //Here add your to email where you have to sent after submitting the form
$subject = 'Test Mail';
$headers = "From: " . strip_tags($uemail) . "\r\n";
$headers .= "Reply-To: ". strip_tags($uemail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>User Name :</strong> </td><td>".$uname."</td></tr>";
$message .= "<tr><td><strong>Email :</strong> </td><td>".$uemail."</td></tr>";
$message .= "<tr><td><strong>Subject :</strong> </td><td>".$usubject."</td></tr>";
$message .= "<tr><td><strong>Message :</strong> </td><td>".$umsg."</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
mail($to, $subject, $message, $headers);
echo "<strong>Contact Form Submitted!</strong>";
?>

これはあなたの問題を解決するのに役立つかもしれないと思います.

于 2013-01-10T07:59:38.607 に答える