plesk

Exporting configured mail accounts and their aliases from the PSA database to csv:

SELECT
	concat(mail.mail_name,"@",domains.name) AS address,
	group_concat(mail_aliases.alias) AS aliases,
	mail.account_id
INTO OUTFILE
	'/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM
	mail,domains,accounts,mail_aliases
WHERE
	mail.dom_id=domains.id
	AND mail.account_id=accounts.id
	AND mail_aliases.mn_id = mail.id
GROUP BY
	address
ORDER BY
	address;