Birmania / smtp-mailing-queue

WordPress plugin - Add emails to a mailing queue instead of sending immediately to speed up sending forms for the website visitor and lower server load.
GNU General Public License v2.0
10 stars 4 forks source link

Queued emails are randomly lost #1

Closed manandre closed 4 years ago

manandre commented 4 years ago

I have started to use the "smtp-mailing-queue" plugin to send to subscribers published articles notification, within the limits of my provider. But I discovered that the number of emails sent did not match the number of subscribers. After analysis of the plugin code, I discovered that the PHP microtime(true) function is used to ensure uniqueness of stored email filename (in json format). But, unfortunately, the obtained precision is often not the microsecond as it depends on the float precision configured in php.ini. So a stored email can be overridden by a next one, as it gets the same microtime() result... Currently, as I cannot change the php configuration (shared server), I have workarounded that by adding "manually" a call to the usleep(20000) function after each call to microtime() to ensure uniqueness, as microtime(true) reports something like 1595870079.9167 on my server. I think we should find a safer uniqueness provider!

Birmania commented 4 years ago

Hi @manandre,

You are right about this uniqueness provider !

What do you think if we update to uniqid function (with more_entropy parameter set to TRUE) ? It also rely on date (which is bad in our case) but more_entropy allow to add combined LCG number at the end. Thanks for your report !

Yours faithfully, Birmania

manandre commented 4 years ago

Yes, good idea! It also has the advantage to keep generating values in the lexicographical order, what permits to send emails in the received order 👍