GoAdmio

mailpwd

Give every email account of one domain a new password (a different random one for each, or one password you choose for all), print the results, and restart the mail services

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · Security · See also


Overview

/go/mailpwd resets the passwords of all email accounts of a domain in one go. It is useful after a security incident, such as a hacked mailbox or a spam campaign, when every account should get a new password.

For each account on the domain, the command:

It then restarts the mail services. To change just one account, use mail with --action edit.

[!WARNING] Every user is locked out until you give them the new password. The passwords are shown only on screen, so save the output right away. See Security.


Quick start

# New random password for every account of example.com
/go/mailpwd example.com

Syntax

/go/mailpwd <domain> [password]
Form Behavior
/go/mailpwd <domain> Each account gets its own random 16-character password (letters and numbers).
/go/mailpwd <domain> <password> Every account gets the same password you give.

Arguments

Position Argument Required Notes
1 <domain> Yes A hosted domain that isn't in the trash.
2 [password] No One password for all accounts. Avoid spaces and single quotes (') in it.

There are no --option value pairs.


Output

Change Multiple Email Account Passwords
info@example.com | k3JdP9xQw2LmZ8Ta
sales@example.com | Vb7RtN4yHs1CqE6u
support@example.com | Xe2MfG5pWd9AaKz3

The command prints a heading, then one line per account. Nothing else is shown while the mail services restart.

Situation Message
The domain isn't hosted, or is in the trash Account Domain <domain> not exists, exit status 1. (See Known limitations: this check doesn't work on Debian and Ubuntu.)
The domain has no email accounts Only the heading is printed, and the services are still restarted.

Examples

# Reset all accounts and keep the passwords in a private file
(umask 077; /go/mailpwd example.com > /root/example.com-passwords.txt)
# Give all accounts the same temporary password
/go/mailpwd example.com 'Temp-Pass-2026'
# Remove the temporary list of addresses the command leaves behind
rm /usr/local/goadmio/example.com.email
# Look up a password later in GoAdmio's database
sqlite3 /var/lib/sqlite/mail.db "select Email,Pass from Mail where Domain='example.com'"

Troubleshooting

Symptom Likely cause Fix
Account Domain <domain> not exists The domain isn't hosted here, is misspelled, or is in the trash. Check the name with the account list.
[[: not found on Debian or Ubuntu The script is started with sh, which doesn't understand that test. The domain check is then skipped. See Known limitations. Pass an existing domain.
Users can't log in Their passwords were changed. Send them the new passwords.
You didn't save the output The passwords are printed once. Read them from the Mail table (see the examples above), or run the command again.
A password with a space or ' fails The value isn't quoted when it is passed on. Use a password with letters, numbers, and simple symbols only.
An account on another domain stopped working See Known limitations: its entry in Dovecot's password file can be deleted by mistake. Set a password for that account with mail --action edit.
Mail was briefly unavailable The mail services are restarted at the end. Expected. Run it at a quiet time.
/usr/local/goadmio/<domain>.email exists The list of addresses is left behind. Delete it.

Details

How it works

flowchart TD
    A["mailpwd domain [password]"] --> B{"Domain hosted?"}
    B -- "No" --> X["Print error, exit 1"]
    B -- "Yes" --> C["List the domain's email accounts"]
    C --> D["For each account"]
    D --> E["Pick a new password"]
    E --> F["Save it in the Mail database"]
    F --> G["Print email and password"]
    G --> H["Replace its line in Dovecot's password file"]
    H --> D
    D --> I["Rebuild Postfix tables, restart mail services"]
  1. Logs the call (including any password you passed) to /var/log/go/mailpwd.log.
  2. Prints the heading.
  3. Checks that the domain exists in the Site table and isn't in the trash.
  4. Writes the domain's email addresses to /usr/local/goadmio/<domain>.email.
  5. For each address, uses the password you gave, or generates a random 16-character one.
  6. Saves it in the Mail table of /var/lib/sqlite/mail.db.
  7. Prints <email> | <password>.
  8. Deletes the account's line from /etc/dovecot/passwd, and adds a new line with the SHA1 hash of the password.
  9. After the last account, runs postmap on custom_replies, vmail_domains, vmail_mailbox, and vmail_aliases in /etc/postfix/.
  10. Restarts postfix, dovecot, saslauthd, and opendkim.

Suspended accounts are included. The command doesn't change anything outside the mail accounts of the domain you name.

Files used

File Purpose
/var/lib/sqlite/mail.db The Mail table: the email accounts and their passwords.
/var/lib/sqlite/site.db Used to check that the domain exists.
/etc/dovecot/passwd Dovecot's logins. Each account's line is replaced.
/usr/local/goadmio/<domain>.email A temporary list of the domain's addresses. It is not deleted afterwards.
/var/log/go/mailpwd.log A log of each call.

Known limitations


Security


See also

Command Description
mail Add, edit, suspend, unsuspend, or delete an email account
vmail Rebuild the Postfix/Dovecot vmail maps
restoremail Recreate mail accounts from folders on disk
outlook Send IMAP/SMTP configuration to email accounts
troubleshoot Troubleshoot email problems in GoAdmio
mailtop Check the most active email accounts in GoAdmio