Tool for creating/sending dynamic emails from DB


I'm looking for a tool or code library that will allow me to create and send emails with dynamic information from our MySQL database. For example, sending a digest email with new connections, alerts, that sort of thing.

Any suggestions?

Email Database

asked Nov 6 '09 at 09:39
892 points

2 Answers


What framework are you normally using to interface to your database? The specific framework and language will heavily influence how you go about this. If you're a developer yourself perhaps you can put this together (though, you probably wouldn't be asking this question then!). For example, if you were using Python, Perl or Ruby, it would probably be a very straight forward task for a programmer to achieve something like this for you.

Is this for internal use (ie. site/server stats & alerts) or as a marketing/newsletter purpose for your customers? All of the major scripting languages have email libraries that will easily do the former. Do you need to completely automate the process? Then sounds again like a server-side script + cron job will be the way to go. Do you need fancy HTML emails, or is plain-text fine? (Again with the script + cron.)

If you need a desktop/end-user solution, OpenOffice's database app can (I think) connect to a MySQL database, and from there you could build a mail-merge system as Jesper suggests, using the other components of the OO suite. It would still be worth finding an OO expert to help you do this though.

The other route would be getting a developer (yourself, employee, freelancer) to write a Thunderbird or Outlook plugin that would interface a MySQL db, pull out the required info, and merging into your mail. Beware that if you do large bulk-emails like thus you may need to talk to your provider to avoid being flagged as a potential spammer.

Good luck!

UPDATE: Justyn, Googling for 'send multipart html email from php' gives a few interesting prospects, but the best and most up to date info is on Stackoverflow (for which this site, OnStartups, shares the same engine). If your developers need help on email and PHP, or other problems with implementing the email system, it will be the best place to go.

It should be relatively straight forward to code some PHP that will allow you to:

  1. Create a HTML email template containing fields that will be filled in with whatever server/system stats or database info you need. (You may need to tie these into command line tools if you want server stats.)
  2. Construct a database query that selects which users should be sent the email.
  3. Schedule automatic and repeat emailing of the template with appropriate fields filled.

All the best!

answered Nov 6 '09 at 13:11
363 points
  • Thanks for taking the time to respond. This would be for an end-user email, similar to what you might get when someone new follows you on Twitter. They will need to be HTML - and I would prefer the server to automate them. I imagine there are plenty of libraries out there we could use for this purpose, but my developers didn't know of any reliable ones. We're using a LAMP stack and PHP, but that's about as far as my technical knowledge goes. Could you possibly point me to a few libraries so I could send to my guys for reference - of even what search term I might use to find some? Thanks! – Justyn 14 years ago
  • Justyn, see above for some searches which may give you the info you need. It prob also worthwhile to add the extra details from your comment to your original question. – User1084 14 years ago


I don't know how well Microsoft Office likes MySQL -- if Office can work with MySQL, then you can do this via Excel, Word and Word's Mail Merge functionality.

answered Nov 6 '09 at 09:44
Jesper Mortensen
15,292 points

Your Answer

  • Bold
  • Italic
  • • Bullets
  • 1. Numbers
  • Quote
Not the answer you're looking for? Ask your own question or browse other questions in these topics:

Email Database