Hey all, I am having a bash at working with flat files. What I am trying to achieve is the following There are 2 files with info in them, file1 has id,email and file2 has id,filename what I am trying to achieve is open up file1 get the id and email then open file2 and match the id of file1 to id of file2, then if succesful send a mail with the filename in file2. Maybe have a look at the code... $recp_list = fopen("mail_group_list.txt", "r"); while(!feof($recp_list)) { $line = fgets($recp_list, 255); $line = chop($line); $split = explode(",", $line); $id = $split[0]; $email = $split[1]; // time to mail. if ($email != "") { $group_list = fopen("file_group_list.txt", "r"); while(!feof($group_list)) { $groupline = fgets($group_list, 255); $groupline = chop($groupline); $groupsplit = explode(",", $groupline); $groupid = $groupsplit[0]; $groupFileName = $groupsplit[1]; if($groupid = $id) { // start mailing $fromname = "Test Mailer"; $fromaddress = "email@xxxxxxxxx"; $subject = "Test mail"; $message = "Test message $groupFileName"; $headers = "From: \"".$fromname."\" <".$fromaddress.">\n"; // Notify the user on screen if the send was succesfull if(mail($email, $subject, $message, $headers)) { print "Mail sent successfully to $email"; } else { print "Mail not sent to $email"; } }#end if groupid = id }#end while group list }#end if email }#end while email !="" ?> So thats the mail.php mail_list_group.txt looks like this 1,test@xxxxxxxx 5,test1@xxxxxxxx 7,test@xxxxxxxx file_group_list.txt looks like this 2,filename1.doc 3,filename2.doc 4,filename3.doc Any help on this would be great ! Cheers Chris PS the formatting might come out all wrong as its mailed from a web account. -- -------------------------------------------------------------------------------------------- Anyone can give up smoking, but it takes a man to face cancer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php