2

I know that I can import a list of email forwarders using CPanel, but how can I delete a list? I want to manage 300+ addresses - as a membership list for my organization. I want to be able to delete that many without clicking 'Delete' and then 'Confirm' (or whatever it is) 300 times. Even if I am able to simply delete ALL forwarders, then upload a modified list - that's fine with me.

Note: I'm using a shared hosting package through SiteGround. The tech service rep informed me that I can't use CPanel scripts in a shared environment. Any suggestions?

2 Answers 2

2

There may well be simpler solutions available, but I myself would write a script that uses the cPanel XML/JSON API to retrieve the list of forwarders, then loop through them and systematically delete all that I found unnecessary. Though, at that point, I suppose you might as well write a script that would allow you to manage the whole shebang outside of cPanel...

Anyway, it looks like API 2's Email Module contains methods for acquiring a list of forwarders and adding them, while API 1's Email Module has a call to delete all of the forwarders associated with a particular domain as well as one to delete individual forwarders, so it may be necessary to use a combination of the two to achieve the desired result.

Hope that helps!

4
  • For sure. Be sure to post back if you work out an alternate solution - I'm quite interested in your question!
    – bosco
    Apr 26, 2013 at 16:12
  • I think that your solution will work generally, but not for me. I have a shared package through SiteGround, and the online CS rep just informed me that I can't run CPanel scripts in a shared environment. I'm inclined to think that there must be a way, but at this point I don't know.
    – psoft
    May 15, 2013 at 18:59
  • I have shared hosting through JustHost, and while I learned that I can not run my own CPanel scripts in a shared environment (via local API calls or calls to the cPanel LiveAPI), I can still access the remote XML/JSON APIs - as it turns out, the two are not one and the same! I recommend trying to fire off an API call with a GET request to know for sure; in my experience my host's support staff didn't quite know what they were talking about ;) .
    – bosco
    May 15, 2013 at 20:22
  • Ok, I will try.
    – psoft
    May 17, 2013 at 19:21
2

I finally discovered that email forwarders can be downloaded and restored as a text file using cPanel's Backup Manager -> Create Backup page.

In that page you can download a list of forwarders for a given domain. The list comes down as a gzipped text file. The filename of this thing is important. It is (at least on my host) alias-<domain>.gz.

You can unpack, edit, and repack this file. The format is simple: one forwarding rule per line. A forwarding rule is a source email address, a colon, then comma-separated list of target email addresses. So that

[email protected] : [email protected], [email protected] 

forwards FUBAR's stuff to SNAFU and TARFU.

Edit this file to your heart's content. Create a new one with a completely different set. Whatever. As long as your source email addresses are in the proper domain, you are in the clear.

Zip it back up, and make sure your new gzip file has the exact same filename as the original you downloaded. Then use the Create Backup Page to restore the backup by uploading your altered gzip. Voilá!

1
  • 1
    Finally!!! I have been trying for 3 years to find an answer for this pesky issue... Worked like a charm. Many thanks!
    – user39262
    Jun 5, 2014 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.