• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Is possible delete all mailboxes at once using REST API v2?

Obistar

New Pleskian
Hi, dear plesk community,
please tell me how can i delete all mailboxes at once using REST API v2?


This is the correct way to delete one mailbox but I need to delete all created mailboxes one time.

# curl -k -X POST -u admin:password "[URL]https://203.0.113.2:8443/api/v2/cli/mail/call[/URL]" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"params\": [ \"--remove\", \"[EMAIL][email protected][/EMAIL]\" ]}"
 
If you go to https://your_plesk_url/api/v2/ you will see that there are no email objects for REST API operations. Only domains, clients, extensions, databases, etc. So, you can use the CLI call for mail command as you wrote in your post. But this command can be executed only for one mailbox. So, there is no ability for mass mailbox deletion with REST API calls.

But you can use the following script for removing all mailboxes:

Code:
# for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select concat(mail.mail_name,\"@\",domains.name) as address from mail,domains,accounts where mail.dom_id=domains.id and mail.account_id=accounts.id order by address"`; do /usr/local/psa/bin/mail -r $i; done
 
Back
Top