I'm adding the ability for users to send their friends eCards to a website, and I'm wondering what the best way to handle this is. I'm concerned about using the mail() function, since it opends up a connection to sendmail. If 1000 users all sent an eCard at the same time, php would open up 1000 connections to sendmail.
I thought about having all eCards added to a database queue, and then running a php script from cron every five minutes or so that would grab these and send them out; this way one connection to sendmail at a time is created.
Ideally what I would like to do (and sorry if my terminology isn't correct) is create some kind of listener service thing. When a user creates a new eCard, I could call something like $eCardMailer->AddNew(), which would add the eCard to the outbound queue. The eCardMailer would then go through the queue, one at a time, and send the card. Is it possible to get it so every user shares the same eCardMailer object. If every user had to create their own instance of the mailer object, then it would be the same as just calling mail().
Also, any other advise for this would be appreciated