Z
Z
zhdanov2012-11-20 19:01:46
PHP
zhdanov, 2012-11-20 19:01:46

How not to wait for an email to be sent in PHP?

I'm using PHPMailer and it hangs when sending email. The mail server thinks for a long time and as a result PHP falls off on a timeout.
Don't want to fork. Maybe someone knows how it can be handled by means of PHPMailer itself?
Tried setting the "Timeout" property, didn't help.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Max, 2012-11-20
@zhdanov

you need to have a sendmail daemon ( qmail ) on the server. It will process the queue. php.net/manual/en/function.mail.php look on the 'queue' page, there are a few ideas there.

E
enchikiben, 2012-11-20
@EnChikiben

Maybe do something like a task scheduler, which adds sending a letter with everything you need, and it runs separately from the script for some period of time.

S
Stanislav Gamayunov, 2012-11-26
@happyproff

Instead of sending, write an email to a json/xml file or database. And run the script that poisons the letter using the cron. If the letter is sent, delete/move the file/record.
It is also very beautifully solved by asynchronous tasks in Gearman.

L
la0, 2012-11-20
@la0

If vds is on something debian - apt-get install exim4-base
or any other mail server you have worked with.
The default configs (as of fall 2011) worked out of the box with no problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question