• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • 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.

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