Plesk – extract all email addresses from database

I recently needed to email everybody on my Plesk server. Traditionally I’ve done this by maintaining an “” list for each subscription but of course that requires constant maintenance.

So instead I did a bit of searching, amended what I found (on the plesk forum I believe), and came up with this (which requires ssh access) –

# log into mysql
mysql -uadmin -p`cat /etc/psa/.psa.shadow`

# Once logged into mysql 
use psa;
select concat(mail.mail_name,"@", as address from mail,domains,accounts where and order by address INTO OUTFILE '/tmp/emailaddresses.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';

# This will create a file /tmp/emailaddresses.csv, which you can email yourself as follows
mail < /tmp/emailaddresses.csv

# and then delete the source file for good measure!
rm /tmp/emailaddresses.csv -f

Leave a Reply

Your email address will not be published. Required fields are marked *