CPanel API

From GoBlueMich Wiki
Jump to navigation Jump to search

whmapi1

https://documentation.cpanel.net/display/SDK/Guide+to+WHM+API+1

listaccts - cli

https://documentation.cpanel.net/display/SDK/WHM+API+1+Functions+-+listaccts

  • List all cPanel usernames
whmapi1 listaccts searchtype=user want=user | grep "user: " | awk '{print $2}'

uapi

https://documentation.cpanel.net/display/SDK/Guide+to+UAPI

Domain Info

list_domains

  • List all domains under a cPanel account
    • Variables = CPUSER
uapi --user=$CPUSER DomainInfo list_domains | egrep -v 'apiversion: 3|func: list_domains|module: DomainInfo|  data:|  messages: ~|  metadata: \{\}|  status: 1'

Email

list_pops - cli

  • List all Email accounts for a domain
    • Variables = CPUSER, DOMAIN
uapi --user=$CPUSER Email list_pops | grep "email:"| grep "@" | grep "$DOMAIN" | awk '{print $2}' | awk -F"@" '{print $1}'


store_filter - cli

  • Add MailSecure filter for blocking mail sent directly to IP, bypassing MS.
    • Variables = CPUSER, DOMAIN, and MAILACCT
uapi --user=$CPUSER Email store_filter filtername="Filter Mail Bypassing MailSecure" account="$MAILACCT"%40"$DOMAIN" action1=deliver dest1="\"$local_part+spam\"@$domain" part1=\$message_headers match1="does not contain" val1="127.0.0.1" opt1=and part2=\$message_headers match2="does not contain" val2="X-Barracuda-Connect"