Hook for after domain/email creation/deletion
I need to run a particular script any time an account is created or deleted, but this also needs to any domain setup for Domain Forwarding. I think pretty much Addon Domains and Parked Domains can be used for this.
I am basically looking to use such a hook for syncing domains with my external spam filter.
I do need to create an email filter every time an email account is created. I know there is an api for creating the filter, but I dont know if there are hooks that can be used to trigger it when an email account is created.
-
Sweet, just figured out part of it. I can place a script in /usr/local/cpanel/hooks/email/, such as addpop, then run: /usr/local/cpanel/bin/register_hooks And now whenever an email account is created, my script runs. Now to see if i can do something like this for addon domains, etc. 0 -
Check out the Standardized Hooks documentation: [url=http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/StdcPanelFunctions]cPanel Functions You can use a hook on any API1/API2 call and other events. With standardized hooks, you can place your hook script anywhere so you're not limited to just one hook per event (there can only be one /usr/local/cpanel/hooks/email/addpop, etc). 0 -
hmm, i have no idea how those Standardized Hooks work. Seems to be limited info on it. Might be easier for me to grasp if i was using perl and knew it better, but I am using php. 0 -
Dave, I was able to get hooks to register using the method you described, but they dont appear to run. I have tried it with the full path or the just the file name (as it says to do), but I get no error in /usr/local/cpanel/logs/error_log and no indication that they have ran (i even tried to have them write to the temp folder to see if they were ran). Any suggestions? [PHP]# /usr/local/cpanel/bin/manage_hooks list Cpanel: Email::addpop: stage: post escalateprivs: 0 weight: 100 id: 4CTB3SjGIqegeMUJrt51bWV2 exectype: script hook: hooks.php -- stage: post escalateprivs: 0 weight: 200 id: xmJIw8rzXBWuZB8yPVRnjWBA exectype: script hook: /usr/local/cpanel/base/frontend/x3/mymx/hooks.php Email::addforward: stage: post escalateprivs: 0 weight: 100 id: Snq3pzwzK6uuBYGvu4jvsciJ exectype: script hook: hooks.php -- stage: post escalateprivs: 0 weight: 200 id: FqYnm0fpM9B4k2yfub1kK1pM exectype: script hook: /usr/local/cpanel/base/frontend/x3/mymx/hooks.php[/PHP] 0 -
[quote="MACscr, post: 1485281">Dave, I was able to get hooks to register using the method you described, but they dont appear to run. I have tried it with the full path or the just the file name (as it says to do), but I get no error in /usr/local/cpanel/logs/error_log and no indication that they have ran (i even tried to have them write to the temp folder to see if they were ran). Any suggestions?
Two things to check. First, you'll need to make sure the PHP files are 0755 as they are being run from the command line via the hook code. Second, you can enable debugging by adding the following line to /var/cpanel/cpanel.config:debughooks=2
This will show you what's happening when the hook fires. You can also set debughooks=3 to see every hookable event in real time to make sure Email::addpop and Email::addforward are being run. Another note is about file location. /usr/local/cpanel/base/frontend/x3/mymx/hooks.php is inside /usr/local/cpanel/base/frontend and as such, the code will be able to be run if someone goes to0 -
Dave, Where is the proper place to store a cpanel plugin in general? /usr/local/cpanel/base/frontend/mypluginname? 0 -
[quote="MACscr, post: 1488262">Dave, Where is the proper place to store a cpanel plugin in general? /usr/local/cpanel/base/frontend/mypluginname?
Unfortunately, there's no real best practices for this but here are different areas of the filesystem that are useful: /usr/local/cpanel/base/frontend - cPanel document root. NOTE: user will always be redirected to their theme document root. code here will not be accessible /usr/local/cpanel/base/frontend/$theme - theme document root. Code here runs under cPanel's webserver (cpsrvd) and has access to built-in cPanel variables. Code is only accessible for users of $theme /usr/local/cpanel/base/3rdparty - used to store 3rd party scripts. Code here executes without extra help from cpsrvd. Code is accessible by users of any theme This makes things a mess because if you want to take advantage of built-in API functionality, you have to place files in a specific theme (or all themes, hoping no one installs a new theme after your plugin is installed). If you want them accessible to all themes by placing them in /3rdparty, then you don't get privileges to execute API and such.0
Please sign in to leave a comment.
Comments
7 comments