You must run this from a cronjob or create a background job or use something even more suitable for batch jobs.
You can receive 14,000 emails in 30 seconds if your mail server is fast enough, but what happens when you get a few more subscribers and stop working properly?
Perhaps you can set a flag in the database for each user, then reset the flag, because their email address is sent by the background job. This will help to avoid duplicates, etc., if there is a problem with the mail server.
source share