Skip to main content

MailMan API with cpanel security tokens cpsess

Comments

10 comments

  • simonm10
    re: MailMan API with cpanel security tokens cpsess [old] Hi mods, where did my post go? Seems to have vansihed:confused: thanks
    0
  • simonm10
    re: MailMan API with cpanel security tokens cpsess [old] I was inspired to post this question by benwiggy's post from 2 years ago:
    0
  • Infopro
    Re: MailMan API with cpanel security tokens cpsess [old] [quote="simonm10, post: 1461961">Hi mods, where did my post go? Seems to have vansihed:confused: thanks
    I've fixed the thread for you. The thread was approved, but you went back in and edited your first post to add bbcode on example links, for some reason. When you did, it put the thread back into moderation. To fix I've merged your first and second posts into one, and killed the original. We're looking at why this is happening in some threads posted by new users. In the meantime, don't edit the first post again, or you'll put it back into moderation.
    0
  • simonm10
    Thanks Infopro for fixing the thread, sorry for the hassle :) In benwiggy's post he says people can PM him if they want to see his code - is there a way to do that? Thanks again!
    0
  • Infopro
    Happy to help. :) He hasn't been active since 2011, no telling if he'll reply to you or not. Hang in there, someone will hopefully be by this thread and have a proper answer for you. :)
    0
  • KostonConsulting
    Here are the cPanel docs about making scripts work with security tokens: [url=http://blog.cpanel.net/making-your-script-work-with-security-tokens-in-cpanel-whm/]Making your script work with security tokens in cPanel & WHM | cPanel Blog Their examples are in Perl but getting an environmental variable in PHP is quite similar. You can get the token with: $token = getenv('cp_security_token');
    This token needs to sit after the hostname like so: https://$hostname:2083$token/frontend/x3/mail/doaddlist.html However, it looks like you are POSTing directly to the pages in cPanel rather than using their API. This means that if they update the page name or field names, your script will no longer work. In order to ensure your script works across cPanel versions, you should connect to API1 and use the Email::addlist() API1 function to add mailing lists: [url=http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api1/ApiEmail#Email::addlist]Email Module Documentation You can connect to API1 easily with the cPanel PHP XMLAPI library and the api1_query() function, if you prefer:
    0
  • simonm10
    Hi Dave, Unfortunately the cpanel mailman API doesn't offer much functionality - just adding and deleting of mailman lists, so it does not do what I need (our scripts set many options, and control the list of subscribers). Hence we are stuck with the not very elegant method of POSTing direct to urls (which is ineligant, but has worked well for many years). Am hoping someone else has coded something in php that I could adapt, I have struggled to write something from scratch myself. Thanks, Simon.
    0
  • simonm10
    Surprised that no-one else has done a script like this...:(
    0
  • cPanelKenneth
    What are the specific actions you want to take in the Mailman admin interface?
    0
  • simonm10
    [quote="cPanelKenneth, post: 1468171">What are the specific actions you want to take in the Mailman admin interface?
    Many things, setting bounce processing options, doing bulk subscribes, setting list privacy options, pretty much any option available from the Mailman web interface, we want to set it via our script.
    0

Please sign in to leave a comment.