Massive creation of virtual accounts

renoproc
2013-12-26
2013-12-27
  • renoproc

    renoproc - 2013-12-26

    Hi,
    I need to create close to 150 virtual mailboxes (MySQL and maildir) and 200
    aliases (MySQL only), and I only have text formatted (csv) listings of these mails and aliases
    addresses.

    I don't see any possibility to do that automaticaly in the postfix admin.
    Is there a way I can deal with this job easily ?

    Thanks for your replies.

     
    • voytek eymont

      voytek eymont - 2013-12-26

      renoproc renoproc@users.sf.net wrote:

      Hi,
      I need to create close to 150 virtual mailboxes (MySQL and maildir) and
      200
      aliases (MySQL only), and I only have text formatted (csv) listings of
      these mails and aliases
      addresses.

      I don't see any possibility to do that automaticaly in the postfix
      admin.
      Is there a way I can deal with this job easily ?

      I'm sorry i can't give you definitive answer, but, I'd think you should be able to make an SQL command to create such, that's what I'd look at.

      ... perhaps do a dump from an installed setup to see what's needed?

      --
      Sent from Kaiten Mail. Please excuse my brevity.

       
  • GingerDog

    GingerDog - 2013-12-26

    Programmatically it'd be easy enough to do.

    If you've got a new enough version of Postfixadmin then you can use the newer cli interface to make it easier.

    IF you're on an older version of postfixadmin then you'd need to create the respective database entries 'manually'.

    David.

     
  • renoproc

    renoproc - 2013-12-26

    Thanks for the reply, I've the 2.3.6 version, seems to be the last one.

    I see that I need to modify create-mailbox.php and the template of the same name, but not enough expert in php to put a csv file importation capability from scratch.
    Can you explain me how I can set a treatment to write a csv list into the db without damages ?

    Thanks a lot.
    Reno.

     
  • Christian Boltz

    Christian Boltz - 2013-12-26

    Actually I have a patch lieing around to mass-create mailboxes, but I didn't merge it yet - and it only can create mailboxes, but not aliases.

    I'd recommend to upgrade to the code in SVN trunk (which we'll release as 3.0 beta really soon - probably in january). Run setup.php to upgrade the database, then use the commandline interface (see "scripts/postfixadmin-cli mailbox add help") to create the mailboxes and aliases. You have to call it in a loop, once for every mailbox/alias.

     
  • Simon Hobson

    Simon Hobson - 2013-12-27

    What you need to do is write a script in whatever programming language you are comfortable that will read your existing data and create some SQL commands to create the domains & mailboxes.

    Lets suppose you have a list with mailbox, domain, password. From that you need to create all the fields in the domains, mailbox, and alias tables. Potentially you can vary this - it depends on what you have - when I did it "some years" ago I had an export from another system so I had a separate list of domains.

    All it takes to create a mailbox is to send two SQL statements to MySQL :
    insert into mailbox values ( <insert values="" here=""> );
    insert into alias values ( <insert values="" here=""> );

    Optionally you can also do an insert into the log table so there's a record of these entries being created. What actually goes in all the fields is fairly simple - just have a browse of existing entries and it should be obvious. The hardest bit (depending on what language you use) may be getting the hashed password correct - IIRC I ripped the hashing code from PFA and adapted it so I could call it from my shell script, but there is probably an easier way !

    As an alternative to doing lots of individual insert statements, you can use your script to write out a set of files suitable to just load into MySQL with a "load" command. The choice is yours as there is no "right" way - and for 150 mailboxes, loaded just once, efficiency isn't really a consideration (ie it's not something you should worry about optimising like you would something run every day).

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks