Here's a question to ask:
I use Ajax on the JS side, which executes the asynchronous way,
When judging xmlhttp.readystate = = 4 o'clock, some data returned by the server will be processed and prompted.
The problem is:
It has recently been found that the data returned by the server can be captured in a long wait.
After tracing, it was found that PHP waits a long time to process a mail function. The mail function simply handles a very simple mail delivery.
There was no such problem before. There may be an exception on the server.
In-depth exploration should be waiting for the mail function's execution to cause the server to return the wait.
Ask if there is a way to solve? The Mail function must be executed when the AJAX call is in the background.
Reply to discussion (solution)
PHP does not support multi-threading, can be the mail function operation Independent, or the mail function to do things, put in a temporary table, timed to send.
This isn't about multithreading, is it? Just this two days the server's mail function seems to be a bit delayed when returning-(actually already has sent out), uses the Linux mail function-only then has this question.
Your question is strange!
Now that you need to wait for mail to return, how can you get around it?
If you want to wait for the mail function to return the result to you, then you can't get around it, my understanding is wrong.
Your question is strange!
Now that you need to wait for mail to return, how can you get around it?
I don't have to wait for mail to return.
I have a mail in the program (), I will be able to delete the normal rapid response; Check the manual, the mail function will return true/false.
That's why I'm guessing it's because waiting for the return of mail causes this slow speed.
How to say, I said wait to return, not my own to wait to return!
In the asynchronous way of Ajax, only the server returns exactly as Xmlhttp.responsetext.
I'm guessing it's because after the mail () function is executed, the client waits for the function to return TRUE or the or will become so slow.
The problem should be the same, I go beyond the statement, the other can be normal execution, Xmlhttp.responsetext will soon be able to capture the value.
So there is no way to remove the mail statement in the case, the normal rapid response?
Mail and email, first check the mail server configuration (for professionals).
Or you can optimize the code, put the message you want to send to a temporary table, Linux plus crontab inside timed to use the mail function to send.
Since you don't have to wait for mail to return, do it according to Nowphp's thoughts.
Of course, you can not know in time whether the e-mail sent
Should be a problem with the mail server.