Question
How to list all forwarding destinations, mailing lists with their members and email aliases for a domain in Plesk via CLI?
Answer
Note: Make sure to replace example.com with the actual domain name when executing any of the below commands.
- Connect to a Plesk server via SSH.
- Execute the following commands:
To list all Email forwarders:
# plesk db "select concat(m.mail_name,'@',d.name) as 'mailbox', mr.address as 'forwarding destination' from mail m left join domains d on m.dom_id=d.id left join mail_redir mr on m.id=mr.mn_id where d.name='example.com' and m.mail_group='true'"
To list all Mailing lists:# domain='example.com';plesk db -Ne "select ml.name from MailLists ml left join domains d on ml.dom_id=d.id where d.name='$domain'"|while read i; do echo "Members of $i@$domain:";/usr/lib/mailman/bin/list_members $i;done
To list all Email aliases:# plesk db "select concat(m.mail_name,'@',d.name) as 'mailbox', concat(ma.alias,'@',d.name) as 'alias' from mail m left join domains d on m.dom_id=d.id left join mail_aliases ma on m.id=ma.mn_id where d.name='example.com' and ma.alias is not NULL"
Comments
0 comments
Please sign in to leave a comment.