Answer the question
In order to leave comments, you need to log in
What to do if the letter is not sent, although there are no php errors?
Hello everyone, I ran into such a problem, I tried to send a message through the mail () function, but for some reason it does not work, there are no errors. Everything is uploaded to the hosting "beget
$mail = "[email protected]";
$message = "Сообщение письма";
if(mail($mail, "Order has been submitted successfully", $message)){
echo "Письмо отправлено";
}else{
echo "Ошибка";
}
" Answer the question
In order to leave comments, you need to log in
First, mail() returns bullshit that doesn't mean anything at all:
Returns TRUE if the message was accepted for transmission, FALSE otherwise.
It is important to note that the fact that the letter was accepted for transmission does NOT mean that it has reached the recipient.
The mail() function calls sendmail, which must be configured. Usually this is a mail server that has a local queue and possibly settings for sending messages to another server (relays with authorization).
And this is quite reasonable, if the remote mail server is not available, then the letter will live in the local queue and wait for the server to be able to accept the letter. And unlike phpmail and the like, the option with a local queue on a local relay looks pretty simple in every way. Otherwise, you will either lose letters if the smtp server is not available, or write a code about queues, and here is hello kafka, gearman, rabbitmq, redis, nemcached and other crutches :) meanwhile, a simple mail() + postfix rises in a couple commands.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question