Generate new email password via SSH on a cPanel server to stop outgoing SPAM emails

Here is a one-liner command that will allow you to generate a new random password for an email account. Simply change the email address and hit enter.

[email protected] ; uapi --user="$(/scripts/whoowns ${email#*@})"  Email passwd_pop email="${email%@*}" password="$(tr -dc 'A-Za-z0-9<=>?@[]\#)(' < /dev/urandom | head -c 64 | xargs)" domain="${email#*@}"

You can also restart Exim and Dovecot services by adding the following code to the command because changing the email password doesn’t end any open sessions with the mail server, allowing them to continue sending emails:

; /scripts/restartsrv_dovecot ; /scripts/restartsrv_exim 

to also remove ALL emails in the mail queue that are from the email you are changing the password for, add:

; exim -bp|grep "$email"| awk {'print $3'}| xargs exim -Mrm

Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.