M
M
maniiii2014-12-06 17:49:05
PHP
maniiii, 2014-12-06 17:49:05

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;});});

there html:
<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>

well, the php handler itself:
$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";
}

SMTP is fine, there seems to be no errors, I tried a bunch of variations (my own / others), climbed a bunch of forums ....
There are suspicions that my brain has temporarily flown away, for a tip from me a bottle of kefir, and if you check it on your server and poke where I am I’m wrong, I’ll treat me to a beer)!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2014-12-06
@BuriK666

See what the mail function returns. If true, look at the mail server logs.

E
Eugene, 2014-12-06
@Nc_Soft

Perhaps the server you're sending from has fallen out of favor. Try a different recipient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question