Does anyone know of a way to display a list of all mailboxes and all forwarders defined on a cpanel server (for all of the accounts)?
A nifty trick I use to find undocumented API2 functionality is to login via SSH and look at the theme files for X3 in /usr/local/cpanel/base/frontend/x3. The themes integrate with the cPanel source code using mostly API2 function calls (though some API 1 calls remain).The XML API is great, btw. I've been working with it in PHP 5 with SimpleXML. It is much easier than the old Accounting system.
One question I still have, though, is how to find a list of the old API 1 calls. I'm trying to setup a script to integrate into another product that displays all the current e-mail boxes for a specific domain name, and allow users to create new ones via a form similar to the one in cPanel.
The addpop example on the cPanel XML API page works, but there doesn't seem to be a way to add a quota.
Is there API documentation for API 1 calls? or is there an equivalent 'addpop' function in API 2? I've not been able to find one, and my "guesses" haven't yet been successful.
Much appreciated in advance.
<cpanel Email="addpop($FORM{'email'},$FORM{'password'},$FORM{'quota'},$FORM{'domain'})">
#!/bin/bash
OWNER=$@
KONTA=`ls -1A /var/cpanel/users/`
count=1
for x in `echo -n "$KONTA"`;do
wiersz=`grep -i ^dns /var/cpanel/users/"$x" |cut -d= -f2`
DOMAIN[$count]=$wiersz
count=$[$count+1]
echo "Login: `echo "$x"`"
for i in `echo "${DOMAIN[@]}" | sed 's/ /\n/g'`;do
for n in ` ls -A /home/"$x"/mail/"$i"/ 2>/dev/null`;do
if [ "$n" == "cur" ];then echo "$n" > /dev/null
elif [ "$n" == "new" ];then echo "$n" > /dev/null
elif [ "$n" == "tmp" ];then echo "$n" > /dev/null
elif [ "$n" == "" ];then echo "$n" > /dev/null
else
echo "$n"@"$i"
fi
done
done
echo;echo;
done
Thanks Grzeslaw. I ran your script and it worked, but it did take a while to run (~10 seconds). Also I wasn't sure about the relationship between the DNS= strings in the user files vs. the user folders (I'm sure it's fine, but I had already started working on my own version) so I just finished this slightly different approach in Perl, which it turned out is also MUCH faster to run.hehe, some time ago, I need to list all resseler mail accounts, so I wrote a simple bash script
use strict;
opendir(USERS, '/var/cpanel/users') || die $!;
while (my $user = readdir(USERS)) {
# user loop
next if $user =~ /^\./; # skip . and .. dirs
opendir(ETC, "/home/$user/etc") || die $! . "/home/$user/etc";
while (my $domain = readdir(ETC)) {
next if $domain =~ /^\./; # skip . and .. dirs
if (-d "/home/$user/etc/$domain/") {
open(PASSWD, "/home/$user/etc/$domain/passwd") || die $! . "/home/$user/etc/$domain/passwd";
while (my $PWLINE = <PASSWD>) {
$PWLINE =~ s/:.*//; # only show line data before first colon (username only)
print "$user,$domain," . $PWLINE . "";
}
close(PASSWD);
}
}
closedir(ETC);
}
closedir(USERS);
opendir(USERS, '/var/cpanel/users') || die $!;
while (my $user = readdir(USERS)) {
# user loop
next if $user =~ /^\.|system/; # skip . and .. and system dirs
if (opendir(ETC, "/home/$user/etc")) {
while (my $domain = readdir(ETC)) {
next if $domain =~ /^\./; # skip . and .. dirs
if (-d "/home/$user/etc/$domain/") {
if (opendir(MAIL, "/home/$user/mail/$domain/")) {
while (my $email = readdir(MAIL)) {
next if $email =~ /^\./;
if (-d "/home/$user/mail/$domain/$email/") {
print "$user $email\@$domain ";
system("du -BM --max-depth=0 /home/$user/mail/$domain/$email/ | cut -f1");
}
}
}
closedir(MAIL); }
}
closedir(ETC); }
}
closedir(USERS);
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
E | Cloudmark blocking our IP - can't get delisted easily - way out? | 2 | ||
R | cPGreyList list_domains | 3 | ||
A | Horde not listing mailboxes from default account login | 1 | ||
![]() |
Horde not listing mailboxes from default account login | 7 | ||
F | List all mailboxes over quota? | 0 |