S
S
Sirex13372019-08-12 00:03:25
PHP
Sirex1337, 2019-08-12 00:03:25

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 "Ошибка";
}
"
All the time displays" Letter sent ", but nothing comes to the mail

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
ThunderCat, 2019-08-12
@ThunderCat

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.

Secondly - check spam, check another email address... Dance naked with a tambourine on a full moon around a server hoster...
Or take a normal library, like PHPMailer, set it up and use it.

A
Anton R., 2019-08-12
@anton_reut

The mail function is blocked by most hosts by default.

M
metajiji, 2019-08-13
@metajiji

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 question

Ask a Question

731 491 924 answers to any question