• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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