大网数据广告活动
网站运营与故障问答

How to bulk delete email accounts from cPanel / my hosting account?

· 52CE 我爱测

I'd like to delete a few hundred email accounts from my domain (it's not all of them). I've looked and looked. cPanel and Hostgator allow you to bulk-create email accounts and forwarders and there may be a way to bulk-delete forw…

问题原文

原帖链接 · Brock Adams · CC BY-SA 3.0

I'd like to delete a few hundred email accounts from my domain (it's not all of them).

I've looked and looked. cPanel and Hostgator allow you to bulk-create email accounts and forwarders and there may be a way to bulk-delete forwarders but there doesn't seem to be a way to delete email accounts -- except one click at a time.

So, if I have 197 email accounts to delete:

[email omitted]
[email omitted]
[email omitted]
[email omitted]
etc...

How can I do this in bulk?

已采纳解答

原帖链接 · Brock Adams · CC BY-SA 3.0

Finally stumbled on the delpop command and cPanel's command-line interface.

So, assuming:

  1. You have SSH access to your account
  2. Your host has installed cPanel in the usual way

Then you can delete a single email account with this command, using an SSH client like PuTTY:

/usr/local/cpanel/cpanel-email delpop account_003 0 mydomain.com



To delete many accounts, all on domain mydomain.com, do this:

  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 your server and cd to the location where you 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
    

    It takes a couple of minutes to loop through 197 accounts and you'll see status messages printing for each account.

  5. Done!

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2014-07-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。