通常のphp投稿を使用するとうまく機能する「友達に送信」phpがあります。このようにして、このPHPがメールを送信できることがわかります。そのため、問題は sendtomail.php ではありません。これも下部に投稿します。
/* Código AJAX Send to Friend*/
$(function() {
$('.error').hide();
$('input.text-input').css({backgroundColor:"#FFFFFF"});
$('input.text-input').focus(function(){
$(this).css({backgroundColor:"#FFDDAA"});
});
$('input.text-input').blur(function(){
$(this).css({backgroundColor:"#FFFFFF"});
});
$(".enterrenvi").click(function() {
// validate and process form
// first hide any error messages
$('.error').hide();
var youremailaddress = $("input#youremailaddress").val();
if (youremailaddress == "") {
$("label#youremailaddress_error").show();
$("input#youremailaddress").focus();
return false;
}
var friendsemailaddress = $("input#friendsemailaddress").val();
if (friendsemailaddress == "") {
$("label#friendsemailaddress_error").show();
$("input#friendsemailaddress").focus();
return false;
}
var dataString = 'youremailaddress='+ youremailaddress + '&friendsemailaddress=' + friendsemailaddress;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "sendtofriend.php",
data: dataString,
success: function() {
$('#message').html("<div id='messagein'></div>");
$('#messagein').html("<h2>Contact Form Submitted!</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#messagein').append("<img id='checkmark' src='images/check.png' />");
});
}
});
return false;
});
});
$(document).ready(function(){
$("input#youremailaddress").select().focus();
});
Sendtofriend.php
<?PHP
$uemail = $_POST["youremailaddress"];
$femail = $_POST["friendsemailaddress"];
$message = "myfootballproject.com";
$link = $_SERVER['HTTP_REFERER'];
$to = "$femail";
$subject = "Tu amigo $uemail te invita a conocer My Football Project";
$headers = "From: $uemail\n";
$message = "Hi $femail. Te invitamos a conocer My Football Project.
$link
$message";
if (mail($to,$subject,$message,$headers) ){ echo "se envío el correo"; }
else { echo "fallo el envío";};
?>
形:
<div id='message'>
<div id='messagein'></div>
<form action="" method="post" id="sendfriendd">
<div id="inpumail" >
<input type="text" name="youremailaddress" id="youremailaddress" size="40" value="" class="text-input" />
<label class="error" for="youremailaddress" id="youremailaddress_error">This field is required.</label>
</div>
<br>
<div id="inpumail2" >
<input type="text" name="friendsemailaddress" id="friendsemailaddress" size="40" value="<%= t('generales.amigcorreoo') %>" class="text-input" />
<label class="error" for="friendsemailaddress" id="friendsemailaddress_error">This field is required.</label>
</div>
<br>
<input type="submit" name="Submit" value=" <%= t('generales.enviarcorreoo') %> " class="enterrenvi">
</form>
</div>