Reputation: 23
I'm in the midst of coding a throttling code in php for outgoing emails.
I want to know what algo is good for throttling?
Can any help to comment on the below design?
Specs:
The emails are stored in MySQL.
PHP will retrieve the data and use PHPmail to send.
The plan so far:
Grab the email column from the database.
Take out the domain, IDs of the records will be paired.
Check the domain (mx & a records).
Update the valid domains in a table.
Sort the domains in stacks of uniques.
Pop each stack once, using the ID to search for the record and send the mail.
Goto next stack, repeat from first stack when done.
Thanks in advance for any help! Jase
Upvotes: 2
Views: 1989
Reputation: 1034
Swift Mailer is a great library to use for sending email from your PHP script. It comes with a Throttler plugin that should do what you want.
Upvotes: 0
Reputation: 48357
In the name of all the gods why?
This is really bad architecture - PHP is a very flexible tool which you could potentially use to implement such a system - but its not the right tool. You should be using PHP to implement the logic of your application - dealing with the peculiarities of the underlying technologies and varying implementations is best delegated to the tools which are specifically designed for the process - in this case the MTA.
This is particularly true when there are well-written off-the-shelf solutions to the problem e.g. milter-limit
And before anyone points out that not everyone has access to reconfigure their MTA - in most cases these people won't have access to run a daemon in PHP
Upvotes: 1