Send bulk messages from PHP

I have 80,000 users on my site and I recently turned my back on the forum script. I used and created myself a very simple one that works just as well (the forum script was too bloated and resource intensive for my simple site)

The only thing that I have lost is the ability to send mass emails to all my members.

So, I'm going to come up with a script to do it myself. After inspecting (including questions here), I decided that using Swift Mailer would be a good idea.

However, I went through all the documentation and don’t see how to send “100 at a time”, and I’m not sure how to do it.

Simply put. I have an admin panel with a form with two inputs "subject" and "message". When I click submit, what is the safest way to send 80,000 emails without crashes on my server or are marked as spam?

I am using a pretty promising dedicated server, so it has no problems with shared servers.

Thanks in advance for any advice!

+5
source share
4 answers

A safe option is to send emails one by one. I usually send no more than 10 emails in 10 minutes. A simple script run by cron is all you need.

- , . ...

+1
0

... , linux. , , , . sendmails.php

<? 
loop through email addresses however you do it
{
 usleep(250000); // sleep for quarter of a second 
 mail('user@example.com', 'My Subject', 'message');
}
?>

, startemails.php

<?
system("&php sendmails.php");
?>

, . 80 000 6 . , .

0

Cron , Swiftmailer . : Cronjob- Swiftmailer 5 , , 10000 ? , , , , , , .

PHP- (bash script ), , ; , Swiftmailer 1 . ( swiftmailer 1). daemonscript 0,5 .

Swiftmailer can handle multiple queues if necessary (you will need to start a second deamon process for each queue).

Unfortunately, Swiftmailer does not have a "send /" folder, so as soon as they are sent, they are gone. Therefore, if an error occurs, you cannot simply move the files from "send /" back to the queue for resending.

0
source

All Articles