Bulk Import of mail accounts

Discussion in 'ISPConfig 3 Priority Support' started by stargazer, Nov 6, 2013.

  1. stargazer

    stargazer Member HowtoForge Supporter

    Is there a way to bulk import e-mail accounts from, say, a CSV file? Would there be an issue with just inserting them into the mail_users table? Or, better still, is there an API that would allow me to simply write some PHP to do it. That would be better as I could then give it back.

    Trying to move several hundred e-mail accounts (from several 10's of domains) into ISPConfig, and would prefer to not have to manually type them, especially since errors can creep in.

    Gwyneth Llewelyn likes this.
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    I've attached a small extension to import mail accounts from csv. install it on your server with the install.sh script, you find it then in the tools menu of ispconfig. There is a example csv file included in the .zip.

    This wont work as your manually inserted values will not exist as config transactions in sys_datalog then.

    There is a remote api available, see remote_client folder in the ispconfig tar.gz file for example scripts and api documentation.

    Attached Files:

    Dan Trautman and kalalalassaa like this.
  3. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    You cannot simply import it into the mail_user database table as this would break ISPConfig workflow.
    There is an API available. Please have a look in the folder "remoting_client/examples" in the tar.gz of ISPConfig stable release.
    There is a mail_domain_add.php and mail_user_add.php that should guide you to what you want to do.
    Be aware that you have to create a "remote user" in ISPConfig (system tab) that has the correspondig privileges.
    Gwyneth Llewelyn likes this.
  4. stargazer

    stargazer Member HowtoForge Supporter

    Thank you both. I assumed since I was not familiar with the code there might be something that would break if I simply did a bulk database load. I will look for the examples.

    Till, that was more than I'd hoped for. I'm still in beta, so I'll put that script in and play with it a little before we try to go live.

    Again, thanks.

  5. stargazer

    stargazer Member HowtoForge Supporter

    Bulk Import Script

    The script works fine, but you must manually edit each entry for it to become active. Is there a way for it to automatically do this?

    To replicate:

    Import one or more e-mail addresses
    Look at /var/vmail/domain_name. Folder for user does not appear (waited 12 hours)
    Edit mail user entry and, with no changes, save
    Mail folder appears within 5 minutes.

    If this is very difficult to do, don't worry about it. The ability to import directly with no errors is a great addition in and of itself, though this behavior should likely be documented.

  6. till

    till Super Moderator Staff Member ISPConfig Developer

    I wrote the script for a older ispconfig release, it might be that its not 100% compatible with the 3.0.5 releases. Instead of editing each record, just go to tools > resync, enable the checkboxes for the mailboxes and start the resync.
  7. stargazer

    stargazer Member HowtoForge Supporter

    Just FYI, hitting resync doesn't work. There may be something about the data that really doesn't get set, I'm guessing. I thought at first it may be because of leading or trailing blanks, but your code clearly does a trim on everything so there is clearly some hook that is not getting fired off or something.

    Anyway, still a useful tool. Cuts way down on the time it takes to import. I have a few days before I have to do anything with the system and, if I get some time, I may try to track it down.

    Again, thanks,

    Gwyneth Llewelyn likes this.
  8. wokka

    wokka New Member

    Till, this is great. Any chance you have a version that will do email aliases and forwards? I have 40 odd mailboxes and another 140 aliases/forwards to build for a conversion from Plesk.


Share This Page