Decreasing page loads when sending email

Sometimes it is necessary to send an email or two after a visitor does something (shopping cart purchase, contact forms, etc.). However, most of the times these don't need to go out right this instant. Many web programming languages are stateless or you might not want to deal with threads.

Whatever your reasons are, its best to just stick them into a DB and run a script with sleep(60) or what suits your needs best in a loop and have it pickup these items and send them at its leisure.

This has sped up certain action from 5-10 seconds to normal speeds of less than 1, as it should be. And why should your customers be punished for your lazyness. Simply create a function that takes the same inputs, then search and replace (sed!) the mail() function with your new function.

Its a bit more difficult if you need to verify the email went out, but at the moment I just always have mine set to return true (if email passed validation in the function).