Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to create several mailboxes in Plesk at once using a single command or a script in the command line?
Answer
-
Create a file
mail.txt
using any text editor with a list of mail addresses and passwords for it:CONFIG_TEXT: example1@example.com password
example2@example.com password
...
exampleN@example.com passwordNote: Make sure that passwords comply with the current Password Strength Policy
-
Follow the instructions below for creating mailboxes from the
mail.txt
file:For Linux-
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
For Windows-
Execute the command below to create mailboxes from the list created on step 2:
Note: In the example below,
mail.txt
file exists inC:\mail.txt
. Adjust the path to themail.txt
file if requiredC:\> 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
-mbox_quota
,-aliases
,-forwarding
etc., can be added to the commandplesk bin mail
in the script. For details on using these options, check the documentation articles: for Linux and for Windows. -
Comments
11 comments
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?
@Martin
Thank you for notice. I have updated the article and now working script is attached.
Hello,
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.
Hello,
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.
Why?
Is it possible to bulk upload email aliases?
@Stefano Poggioli
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.
@Nikolai Graf-Rüssel
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?
Hi Nikolay,
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.