cpanel (2)


Quick WHM/cPanel All email passwords reset

You generally don’t want to use this script. This is a last resort, when all mailbox passwords for the entire account need to be changed. For this script to work, you need root access to your WHM/cPanel server. This could ruin everything, be warned!

Here be dragons!

#!/bin/bash
newpass='SomeStr0ngPasswordGoesHere!'
accountname='example'
domainname='example.com'

uapi --user=$accountname Email list_pops \
  | grep email \
  | awk '{print$2}' | awk -F\@ '{print$1}' | \
  while read m; do
    echo changing password for $m
    uapi --user=@accountname Email passwd_pop domain=$domainname email=$m password=$newpass
  done
echo done

Here are the links to the official API docs:

  • https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Email%3A%3Apasswd_pop
  • https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Email%3A%3Alist_pops

Is there a better way to do this? probably

Can I randomize the password? sure, but how will you send the new passwords to your users?

Hope it helps!

Similar Posts:




Exim mail queue cleanup

I wrote before about cleaning up the mail queue. I had a large queue today though and the exim tools “felt” slow. So I did it manually (which wasn’t much faster):
cd /var/spool/exim/input/
for d in *; do echo in $d; cd /var/spool/exim/input/$d; C=0; for x in *H; do grep -q example.com $x; if [ $? -eq 0 ]; then f=${x%H}; (( C++ )); rm ${f}{H,D}; fi; done; echo $C mails deleted; echo "remaining: "; ls -l | wc -l; echo ---; done

Similar Posts: