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!
Top comments (0)