Jul 16

Script to add many user email address on qmail vpopmail

Uncategorized Comments Off on Script to add many user email address on qmail vpopmail

If you have qmail vpopmail mail system and you want to add a new user and the amount of the new user is huge here is some script to add them. I assume you have the new email address list on mailinglist.txt( at the end of the list makesure you don’t have any space because it will create a blank email address on your qmail system)


< ?php
$handle = fopen("mailinglist.txt", "r");
$counter=0;
while (!feof($handle)) {
$userinfo = fscanf($handle, "%[a-zA-Z0-9._ ],%[a-zA-Z0-9. ],%[a-zA-Z0-9. ]" );
if ($userinfo) {
list ($email, $name, $password) = $userinfo;
$counter++;
$email=trim(strtolower($email));
$name=trim($name);
$password=trim($password);
echo "username : $email@test.org password : $password name : $name \n";
exec("/home/vpopmail/bin/vadduser $email@test.org $password -c '$name'");
exec("/usr/local/bin/ezmlm/ezmlm-sub /home/vpopmail/domains/test.org/mailinglistname/ $email@test.org"); #to add user to your mailinglist
}
$userinfo=NULL;
}
fclose($handle);
echo "Adding $counter users";
?>

save it as qmail.php and run it on your shell
# php qmail.php