0

This is my task:

I have form.

User set title and content of email. I have database with f.e 50 000 emails.

Now I need to send this title+content to every email. How can I do it from server? With function mail(); it will be too long. I need to send 10 emails per 1 minute. How to set it? When I close tab it should send emails as long as every email get title+content.

Charlie
  • 22,886
  • 11
  • 59
  • 90
patwoj98
  • 449
  • 2
  • 16
  • can you post the code – lyndact Nov 19 '15 at 17:33
  • I don't have code now. I need an idea how to do that. I don't know what should I do to do it. – patwoj98 Nov 19 '15 at 17:35
  • ok we can try to find an idea for you – lyndact Nov 19 '15 at 17:38
  • 1
    There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.I would suggest that you find a development forum (perhaps [Quora](http://www.quora.com/Computer-Programming)?) to work out generalities. Then, when/if you have specific coding issues, come back to StackOverflow and we'll be glad to help. – Jay Blanchard Nov 19 '15 at 17:56
  • I edited issue. Iam programmer ;) – patwoj98 Nov 19 '15 at 18:01

1 Answers1

2

Get the mail() to do it in php while calling the script correctly for it to persist until the end of the operation even the user agent is closed.

This answer describes how to do it:

It's a race condition. PHP will detect at some point (usually upon attempting to do output) that Apache is yelling in its face that the remote user has closed the connection. Whether everything you wanted to do is done at that point depends on how your code's structured.

If you want to ensure that all operations are complete before the script shuts itself down, use ignore_user_abort(TRUE), which keeps PHP running after the connection is severed. It's still subject to the user max_execution_time limits and whatnot, but it will not shut down because you disconnected.

And this answer shows you an accurate way to do it:

Certainly it can be done with PHP, however you should NOT do this as a background task - the new process has to be dissocated from the process group where it is initiated.

Since people keep giving the same wrong answer to this FAQ, I've written a fuller answer here:

http://symcbean.blogspot.com/2010/02/php-and-long-running-processes.html

Community
  • 1
  • 1
Charlie
  • 22,886
  • 11
  • 59
  • 90