Help, please, with php sending messages to the mail of users. Cannot send, although it returns true. Code like this

$mail = mail("user@mail.ru","Hello","Text"); if($mail = true) echo "message Sended"; 

This piece is taken from the example in the manual and, in principle, is simple until it is completely stupefied, but does not work, can you tell me why? I will be grateful!

The site is not local, but on hosting.

  • Maybe the message is sent and just get in spam? If not - are there any php errors? And in general - what exactly did you do, how was it checked? - Zowie
  • How did you check? I put the code on the site of the host there it is written that everything is truer (according to the authors of the manual, this means that everything should work), but the letter does not reach - mixail
  • How did you check that the letter, I quote - "does not reach"? And yes - if the result of mail() true - then the letter is delivered (in any case, everything that depended on PHP is completed) - Zowie
  • I did not get the letter you ever wrote the code sending messages to users? No one seems to be able to help here - mixail
  • Yes, I wrote and, not rarely, this message gets into spam Theoretically, it can even be blocked ... (this is only an assumption) - Zowie

1 answer 1

 $mail['charset'] = "windows-1251"; $mail['to'] = ""; // Кому $mail['from'] = ""; // От кого $mail['subject'] = $_POST['subject']; $mail['massage'] = $_POST['massage']; $mail['header'] = "MIME-Version: 1.0\n" ."From: " . $mail['from'] . "\n" ."X-Priority: 3\n" ."X-Mailer: Mailer\n" ."Content-Transfer-Encoding: 8bit\n" ."Content-Type: text/html; charset=" . $mail['charset'] . "\n"; mail ($mail['to'], $mail['subject'], $mail['massage'], $mail['header']); 

Try this code! If deaf, then problems with the hoster!

  • one
    Why massage ( $mail['massage'] )?) - timka_s
  • 2
    exclusively for prettiness ) - Palmervan
  • Friends to all BIG THANKS thanks for having decided to help, but it turns out that just sending a message requires a paid hosting service, and in the test period they disable this service in php.ini I'm a beginner php-person and I don’t know how to write for sure but I would like to check if it works correctly ( ( - mixail