I have been looking for the same thing and I ran across this article:
http://www.dynamicdrive.com/forums/showthread.php?50825-How-to-do-Mail-Merge-with-php-and-MySQL
Essentially they suggest using the file() function to pull the file contents into an array and then loop on the array with str_replace(). Obviously this means that the strings you want to replace need to stand out (the questioner was using % at the beginning and end of each string), but if I'm not mistaken mail merge tags are identified with '<< >>'.
Good luck!