Extract Plesk Mailbox Usernames

When you require a full overview of all usernames of your mailboxes on a Plesk server, it’s best to use the command line and extract this information using MySQL. The following query will show you all usernames of mailboxes, including the domain that they belong to:

# mysql -uadmin -p` cat /etc/psa/.psa.shadow` -Dpsa -e"select mail_name,name,password from mail left join domains on mail.dom_id = domains.id inner join accounts where mail.account_id = accounts.id ORDER BY name;"

This will give you the following information:

+-------------+--------------------+-------------+
| mail_name   | name               | password    |
+-------------+--------------------+-------------+
| mailuser1   | domainname1.com    | password    |
| mailuser2   | domainname1.com    | password    |
| mymailbox1  | domainname2.com    | password    |
| mymailbox2  | domainname3.com    | password    |
+-------------+--------------------+-------------+

On older versions of Plesk, you will see the actual password here. Newer versions of Plesk will only show you the AES encrypted password.

Of course, you can also run a query that shows the usernames of the mailboxes for a single domain name:

# mysql -uadmin -p` cat /etc/psa/.psa.shadow` -D psa -e"select mail_name,name,password from mail left join domains on mail.dom_id = domains.id inner join accounts where mail.account_id = accounts.id AND name='domainname1.com' ORDER BY name;"

And you will see all mailboxes for this domain name:

+-------------+--------------------+-------------+
| mail_name   | name               | password    |
+-------------+--------------------+-------------+
| mailuser1   | domainname1.com    | password    |
| mailuser2   | domainname1.com    | password    |
+-------------+--------------------+-------------+

I hope this has been useful to you. Feel free to leave a comment if you have any questions.