Answer the question
In order to leave comments, you need to log in
Sending Email php+ajax, SMTP enabled. I can't figure out what's the problem?
I can’t figure out if I’m a fool, or the skis don’t go.
There is the most primitive script that sends a notification to email, it has been working properly all its life and without any complaints, but for the third day it has stubbornly refused to work.
I decided to score and write an even more primitive thing, which also does not work.
jquery example:
$(document).ready(function(){
$('#submit').click(function(){
$.post("send.php", $("#mycontactform").serialize(), function(response) {
$('#success').html(response);});
return false;});});
<form action="" method="post" id="mycontactform" >
<label for="name">Name:</label><br />
<input type="text" name="name" id="name" /><br />
<label for="email">Email:</label><br />
<input type="text" name="email" id="email" /><br />
<label for="message">Message:</label><br />
<textarea name="message" id="message"></textarea><br />
<input type="button" value="send" id="submit" /><div id="success" style="color:red;"></div>
</form>
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = '[email protected]';
$subject = 'the subject';
$message = 'FROM: '.$name.' Email: '.$email.'Message: '.$message;
$headers = 'From: [email protected]' . "\r\n";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
mail($to, $subject, $message, $headers);
echo "1";
}else{
echo "0";
}
Answer the question
In order to leave comments, you need to log in
See what the mail function returns. If true, look at the mail server logs.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question