Bulk delete email accounts from cPanel in SSH?
Hi,
I have found the following procedure to bulk delete email account for a domain.
1. Create a text file, delemails.txt, with each account name on its own line:
account_003
account_004
account_012
account_027
etc...
2. FTP that file onto your server into a convenient location.
3. SSH onto the server and cd to the location where is placed delemails.txt
4. Run this command from the SSH shell:
for i in `cat delemails.txt`; do /usr/local/cpanel/cpanel-email delpop "$i" 0 mydomain.com ; done
Do you thinks is it safe to use that?
-
Hi, That is fine, but the same thing you can also do using WHMAPI2. You can refer to the below link for more details: cPanel API 2 Functions - Email::delpop - Developer Documentation - cPanel Documentation 0 -
Hello As stated by @24x7server the cpapi2 delpop function can also be used but you'd need to create a loop for it as well. Thanks! 0 -
Need help to on this issue i'm able delete emails directory but email not removed from email option find -path "*/mail/*" -type d -name "smtp" -exec rm -rf "{}" \; 0 -
uapi --user={SPECEFIC USER NAME} Email delete_pop email='{SPECEFIC EMAIL ADDRESS}' yes it helped me to delete email when i specifically add user name and specific email address. uapi --user={ALL USERS IN MY SERVER} Email delete_pop email='{ALL EMAIL STARTS FROM WORD smtp @ ALL DOMAINS' I want a loop like this please help to generate a loop or documentations I can follow to make this loop. 0 -
cat emaillist.txt | while read EMAIL;do uapi --user={cpanel username} Email delete_pop email=$EMAIL;done Now just problem left in cPanel usernames fetching that i have tried with 2 methods 1) extract domain name from email address that i have already list. then cPanel account name based on that extracted domain .. but no luck I have tried regex to get domain name. URI=" 0 -
I'm not completely sure what you're trying to do with the usernames. Can you let me know specifically what you're trying to do and what data you're trying to pull? 0
Please sign in to leave a comment.
Comments
9 comments