向用户发送电子邮件提醒的方法 - 进程

I have built a task management system. I want to send an email to users that have an outstanding task that's over a certain time old, as a reminder.

What's the best approach doing this via a php script:

A) query the database and get relavant user emails, pop them into an array and then send emails

B) query database and at the point of finding a relavant user send the email immediately and then continue loop

I'm assuming mixing the querying with the sending of emails is probably not a good idea, and would be best to split the two processes?