If you're looping through your database for address sending emails to each and everyone there is a large chance for you to receive a server timeout message.
The scrip which I've put together starts at 0 and up to about 50 emails then the page is reloaded and the script sends 50 more. Because of that I never get a timeout message.