Skip to main content

Bulk delete email accounts from cPanel in SSH?

Comments

9 comments

  • 24x7server
    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
  • cPanelLauren
    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
  • aadii786
    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
  • cPRex Jurassic Moderator
    @aadii786 - deleting the file structure would not remove the email accounts from cPanel. You'd want to use the API call to properly remove the email account:
    0
  • aadii786
    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
  • cPRex Jurassic Moderator
    I don't have a ready-made loop for this situation, but a "for" or "while" loop would work well for this. We have an example of this work here:
    0
  • aadii786
    I don't have a ready-made loop for this situation, but a "for" or "while" loop would work well for this. We have an example of this work here:
    0
  • aadii786
    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
  • cPRex Jurassic Moderator
    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.