• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

Question Script Change Password all Mailbox

marcelhalls

New Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
18.0.61
I need to change the password for all email boxes on a specific domain in order to migrate the boxes with imapsync.
I tried the script below but when I run it, it returns the following error: " The specified email address is not valid. Specify a valid one that matches the following pattern: [email protected]. "

Below is the script I used:

Bash:
#!/bin/bash

# Set the specific domain
DOMAIN="example.com"
# Set new password
NEW_PASSWORD="newSecurePassword"

# Get the list of email accounts for the specified domain
ACCOUNTS_EMAIL=$(plesk bin mail -l | grep "@$DOMINIO" | awk '{print $1}')

# Iterate over each email account and change the password
for EMAIL in $CONTAS_EMAIL; of
 echo "Changing account password: $EMAIL"
 plesk bin mail --update "$EMAIL" -passwd "$NEW_SENHA"
done

echo "Password change completed."
 
Last edited by a moderator:
How did you came up with that script? It contains a number of errors and inconsistencies that you need to solve first.
 
Try this:

Bash:
#!/bin/bash

# Set the specific domain
DOMAIN="example.com"
# Set new password
NEW_PASSWORD="newSecurePassword"

# Get the list of email accounts for the specified domain
ACCOUNTS_EMAIL=$(/usr/local/psa/bin/mail --list | grep "@$DOMAIN" | awk '{print $3}')

# Iterate over each email account and change the password
for EMAIL in $ACCOUNTS_EMAIL; do
 echo "Changing account password: $EMAIL"
/usr/local/psa/bin/mail --update "$EMAIL" -passwd "$NEW_PASSWORD"
done

echo ""
echo "Password change completed."
 
Try this:

Bash:
#!/bin/bash

# Set the specific domain
DOMAIN="example.com"
# Set new password
NEW_PASSWORD="newSecurePassword"

# Get the list of email accounts for the specified domain
ACCOUNTS_EMAIL=$(/usr/local/psa/bin/mail --list | grep "@$DOMAIN" | awk '{print $3}')

# Iterate over each email account and change the password
for EMAIL in $ACCOUNTS_EMAIL; do
 echo "Changing account password: $EMAIL"
/usr/local/psa/bin/mail --update "$EMAIL" -passwd "$NEW_PASSWORD"
done

echo ""
echo "Password change completed."


Worked perfectly!

Sorry for the delay in responding, I was away these days.

Thank you one more time!
 
Back
Top