How to get all email accounts by API?
Hi there!
Is there a way to get all the email accounts under the WHM level by using a single API call?
It says everywhere that this would require some scripting to automate the process and aggregate the results by using listaccts first and then iterating through by Email::list_pops endpoints
We'd like to get all email accounts with a single API fired.
Thanks in advance.
-
Hey there! Unfortunately I don't. Everything you've found about looping through Return email accounts with each user is the best option I have at this time. 0 -
Well, it's not *really* that difficult in my estimation. Basically the process is: * Get the accounts via `listaccts` API call * Iterate over accounts and run `list_pops_for` API call on each of them (or use WHMAPI batch to run it for all of them in one shot -- that'd probably be the best way). Thankfully, whmapi.pl does not impose any RFC based restrictions on URL length, so even a GET with 1000 accounts specified in the batch call should still work properly. That said, I'd probably submit that one as a POST just to avoid sending usernames over the wire unencrypted (as all URLs go across that way). An example of the output when using the CLI looks like: # bin/whmapi1 --output=jsonpretty batch command='list_pops_for?user=cptest' command='list_pops_for?user=reselleur' { "data" : { "result" : [ { "data" : { "pops" : [ "test@cptest.local" ] }, "metadata" : { "command" : "list_pops_for", "reason" : "OK", "result" : 1, "version" : 1 } }, { "data" : { "pops" : [] }, "metadata" : { "command" : "list_pops_for", "reason" : "OK", "result" : 1, "version" : 1 } } ] }, "metadata" : { "command" : "batch", "reason" : "OK", "result" : 1, "version" : 1 } }
Of course for an HTTP request, you'd want to URI encode the values passed in ascommand
if doing this as a GET, but that should go without saying (and our docs for batch also mention this).0 -
Thanks! The batch function seems to be really useful 0
Please sign in to leave a comment.
Comments
3 comments