• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

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