How TolinuxupdatePlesk

Plesk How-To: Export List of Mail-enabled Domains

Note: you'll need access to the psa database. Tested on Plesk 18.0.30.

Plesk stores most of its information in the psa database, so getting information out can usually be done via an SQL query. To export a list of all domains with emails enabled, run the SQL query below:

select distinct from mail,domains where order by name;

If you want to store the output in a text file, you can add INTO OUTFILE ‘/location’ into the query:

select distinct INTO OUTFILE '/tmp/output.txt' from mail,domains where order by name;

Lastly, if you wanted to put this into a Bash script (e.g; to send over a list of mail-enabled domains to a spam filtering server) you can run:

plesk db "select distinct INTO OUTFILE '/tmp/output.txt' from mail,domains where order by name;"

The above command can be run by anybody with root privileges and will output a list of all mail-enabled domains to /tmp/output.txt. Note that MySQL cannot overwrite existing files, so you will need to add a line into your script to remove the file before running the command above.

Jonathan Procter

Linux, Unix, and Windows server sysadmin.

Related Articles

Check Also
Back to top button