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.


# 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 (<>) {

       # 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.


We developed our own interface for Zimbra account management some years back for 6.0.8. At the time, soap support was not that well documented and took some trial and error.

There are some PHP classes available on Google code anf GIThub.

See http://www.plymouth.edu/webapp/code/zimbra.class.phps or https://github.com/libersoft/zcs-php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.