How are you sending the mail? Are you using something like mailgun or what service are you using to send it? Did you update your .env settings for mail?
Email function not working
I recently created a laravel application. In that, there was a section enquiry which deals with getting enquiries from users and sending it to the given email. The function works correctly when deployed in local host but shows alert when deployed in server system. What can the reason be?
what alert, where? you are not giving much away...
var sentMail = function(name,email,message){
var data2 = {"name":name,"email":email,"message":message};
var postData = {"data":data2};
$.ajax({
type: "POST",
crossDomain: true,
data : data2,
url: '/MaxloreSite/sentmail/sent.mail.php',
success: function(result){
if(JSON.stringify(result)=='"Message successfully sent!"'){
$("#mydiv").hide();
swal({
text:"Message sent successfully !!",
type: "success",
timer: 3000
});
$("#from1")[0].reset();
}else{
$("#mydiv").hide();
swal({
text: "Error please try again !!",
type: "error",
timer: 3000
});
}
},
error:function(result){
$("#mydiv").hide();
swal({
text: "Error please try again !!",
type: "error",
timer: 3000
});
//alert(JSON.stringify(result));
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With');
}
});
}
does that look readable to you?
please format your code
what is the php code? Is that laravel or some function you found somewhere?
The code is a php code which is stored as a js file which is used to send an enquiry from the user side and it is received by the server.
The javascript you are showing isn't php, doesn't contain any php, and it isn't sending an email. It might be triggering something that sends an email, but it itself isn't. The problem is probably in the `url: '/MaxloreSite/sentmail/sent.mail.php', file that the ajax request is being sent to.
Can that php file be seen through inspect in google chrome?
Just the url to it (since it's in your javascript), but no, you can't see the "contents" of it.
OK. Then i can send the contents after around 11 hours only. Since I am not in office now.
Is this even a laravel app? Normally, you don't post directly to a .php file, you post to a url that laravel routes to a controller. So far, you've shown nothing related to laravel?
Please or to participate in this conversation.