- Plesk for Linux
- Plesk for Windows
How to create several mailboxes in Plesk at once using a single command or a script in the command line?
Create a file
mail.txtusing any text editor with a list of mail addresses and passwords for it:
CONFIG_TEXT: email@example.com password
Note: Make sure that passwords comply with the current Password Strength Policy
Follow the instructions below for creating mailboxes from the
Download the attached script:
# wget https://support.plesk.com/hc/en-us/article_attachments/360014711094/createmail_.tar.gz
Unpack the downloaded archive:
# tar -zxvf createmail_.tar.gz
Execute the script:
# ./createmail.sh mail.txt
Execute the command below to create mailboxes from the list created on step 2:
Note: In the example below,
mail.txtfile exists in
C:\mail.txt. Adjust the path to the
mail.txtfile if required
C:\> for /F "tokens=1,2 delims= " %i in (c:\mail.txt) do plesk bin mail.exe -c %i -passwd %j -mailbox true
Note: Other options like
-forwardingetc., can be added to the command
plesk bin mailin the script. For details on using these options, check the documentation articles: for Linux and for Windows.
The script returns: -bash: ./createmail.sh: /bin/bash^M: bad interpreter: No such file or directory when obtained from wget
This is probably caused by MSWin line endings?
Thank you for notice. I have updated the article and now working script is attached.
I created the file mai.txt with the format: "user@domain password"
but after in the script i see "insertpasswordhere" means every account will be created with the same passwords.
After research i executed this script:
for /F "tokens=1,2 delims= " %i in (c:\mail.txt) do plesk bin mail.exe -c %i -passwd %j -mailbox true
And now the scripts creates the user with the password from file mail.txt.
if some password is not complex enought will show you the status.
Hello @Bernardo Murillo!
Thank you very much for the input.
I have updated the article accordingly.
everithing seems to be working properly with no errors but...
passwords are not taken correctly (I set up the txt file as described).
In fact, if a user tries to use the email address or enter webmail, the password is not recognized.
If I re-enter the same passwords in plesk email setup, they become correct.
Is it possible to bulk upload email aliases?
In case you do it on Windows, I can assume that 'mail.txt' is not well-formed. Try to use the default notepad.exe or notepad++ to edit the input file.
On Linux, the same may apply if the graphical document editor is used instead of a simple text editor.
Unless I am missing something, the article addresses exactly it.
Could you clarify your use-case in more detail?
This is just for whole mailboxes.
I just want to add to a mailbox more aliases. Can I do that via bulk with a single script?
Please check documentation and use the same approach combining "for" and command line to do scripts:
For details on using these options, check the documentation articles: for Linux and for Windows.
thanks thats it!
Please sign in to leave a comment.