How to create several mailboxes on Plesk server at once using a single command or a script?

Follow

Comments

11 comments

  • Avatar
    Myhost

    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?

    0
    Comment actions Permalink
  • Avatar
    Bato Tsydenov

    @Martin

    Thank you for notice. I have updated the article and now working script is attached.

    0
    Comment actions Permalink
  • Avatar
    Bernardo Murillo

    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.

    0
    Comment actions Permalink
  • Avatar
    Alexandr Redikultsev

    Hello @Bernardo Murillo!

    Thank you very much for the input.

    I have updated the article accordingly.

    0
    Comment actions Permalink
  • Avatar
    Stefano Poggioli (Edited )

    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?

    0
    Comment actions Permalink
  • Avatar
    Nikolai Graf-Rüssel

    Is it possible to bulk upload email aliases?

    0
    Comment actions Permalink
  • Avatar
    Denis Bykov

    @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.

    0
    Comment actions Permalink
  • Avatar
    Denis Bykov

    @Nikolai Graf-Rüssel
    Unless I am missing something, the article addresses exactly it.
    Could you clarify your use-case in more detail?

    0
    Comment actions Permalink
  • Avatar
    Nikolai Graf-Rüssel

    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?

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    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.

    1
    Comment actions Permalink
  • Avatar
    Nikolai Graf-Rüssel

    thanks thats it!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request