We have a zimbra mail server for the members and all members have e-mail addresses which we give them to use our services like signing in the wireless network and etc.. Memberships are temporary. We will have new members and leaving members for every six month period. For now we have created current members uploading their information from .csv file. After six months we will have to disable current mail accounts and add new ones.
What I want to do is to accomplish those tasks using PHP. I have found some examples on Zimbra's wiki page. They show how to create accounts reading from .csv files using Perl.
#!/usr/bin/perl
# Lookup the valid COS (Class of Service) ID in the interface or like this
my $cosid = `su - zimbra -c 'zmprov gc Default |grep zimbraId:'`;
$cosid =~ s/zimbraId:\s*|\s*$//g;
while (<>) {
chomp;
# CHANGE ME: To the actual fields you use in your CSV file
my ($email, $password, $first, $last) = split(/\,/, $_, 4);
my ($uid, $domain) = split(/@/, $email, 2);
print qq{ca $uid\@$domain $password\n};
print qq{ma $uid\@$domain zimbraCOSid "$cosid"\n};
print qq{ma $uid\@$domain givenName "$first"\n};
print qq{ma $uid\@$domain sn "$last"\n};
print qq{ma $uid\@$domain cn "$uid"\n};
print qq{ma $uid\@$domain displayName "$first $last"\n};
print qq{ma $uid\@$domain zimbraPasswordMustChange TRUE\n};
print qq{\n};
}
How can I run those zimbra commands using PHP file? I want to read list from a .csv file and create and/or disable accounts on the server.