. If you cannot use that, which is a shame, the way you are doing this is re-starting sendmail for each email address. Rather than sendmail, i would suggest using SMTP (there are a few modules for this).
When you go to mysql, make sure to us DBI, this is not usually a problem with MySQL, but always like to remind people that DBI is nice.