Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

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!

share|improve this answer
    
I will take a look. Thanks –  psoft Apr 25 '13 at 3:59
    
For sure. Be sure to post back if you work out an alternate solution - I'm quite interested in your question! –  boscho Apr 26 '13 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 '13 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 ;) . –  boscho May 15 '13 at 20:22
    
Ok, I will try. –  psoft May 17 '13 at 19:21
add comment
up vote 1 down vote accepted

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

fubar@gmail.com : snafu@gmail.com, tarfu@comcast.net 

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á!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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