1); $params['group'] = $groups; $result = civicrm_contact_search( $params ); // Process the search results $nrows = 0; foreach ($result as $id => $values) { if ($values['email'] != '') { $fix_displayname = str_replace(' ', ' ', $values['display_name']); // remove extra spaces in some names $line = trim($fix_displayname) . ' <' . trim($values['email']) . '>' . "\n"; fwrite($f, $line); $nrows++; } } if ($nrows > 0) { // Zero rows is probably an error // Run the mailman sync_members command $command = "/usr/sbin/sync_members $mmparams -f $tmpfilename $mmlistname 2>&1"; echo "Running $command\n"; #[ML] $output = shell_exec($command); #[ML] do not delete members for now $output = shell_exec("/var/lib/mailman/bin/add_members -r $tmpfilename -w n -a y $mmlistname 2>&1"); echo $output; } else echo "WARNING no rows... skipping sync command.\n"; // Close the temporary file fclose($f); // unlink($tmpfilename); } SyncList('membres-facil.qc.ca','3'); // specify your mailing list name and CiviCRM group id here // repeat for each list ?>