I rolled my own solution. I found that each cPanel user has a YAML file in ~username/.cpanel/email_accounts.yaml
which contains information about all email accounts under that cPanel user's account. Using that I whipped up a short Ruby script:
#!/usr/bin/ruby
require 'yaml'
puts "email,username,domain,usage,quota"
Dir.glob('/home/*/.cpanel/email_accounts.yaml') do |email_accounts_file|
email_accounts = YAML.load_file(email_accounts_file)
#puts email_accounts_file
#puts email_accounts.inspect
#puts "---------------------------"
email_accounts.each do |domain,info|
if info['accounts'] then
#puts "domain: #{domain}"
info['accounts'].each do |username,info|
puts "#{username}@#{domain},#{username},#{domain},#{info['diskused']},#{info['diskquota']}"
end
end
end
end
The script should br run as root and loops through all directories under /home
looking for .cpanel/email_accounts.yaml
files. (If your users' home directories are not stored as /home/username
then edit line 7) The script prints out CSV separated data of all email accounts, what domain name they belong to, and what their disk usage and quota is, as reported by the YAML file.