1

Topic: Import users from txt file possible?

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.8
- Linux/BSD distribution name and version: ubuntu 16.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): SQL
- Web server (Apache or Nginx): nginx
- Manage mail accounts with iRedAdmin-Pro? yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hi,

I have a list of ~300 Users for one single Domain. I found in older versions of iredmail it was possible to import a list of users via script, but it seem's this script doesn't have the option anymore. (https://forum.iredmail.org/topic6979-ir … -file.html)

Is there any way to do so in iredmail 0.9.8 SQL Edition?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Import users from txt file possible?

lug wrote:

- Manage mail accounts with iRedAdmin-Pro? yes

How about use the iRedAdmin-Pro RESTful API?
https://docs.iredmail.org/iredadmin-pro … #mail-user

Write a simple shell script to get different preference for one single user from the text file, then post to API.

3

Re: Import users from txt file possible?

Thanks, didn't know about that api.

For everyone who's interested:

#!/bin/bash
USER='postmaster@example.org'
PASS='xyz'
RANPASS='xyz123'

curl -X POST -c cookie.txt -d "username=$USER&password=$PASS" https://mail.example.org/iredadmin/api/login

users=$(cat /root/lug/list.txt)
domain="example.org"

for i in $users
do
        curl -X POST -i -b cookie.txt -d "name=$i&mailQuota=0&password=$RANPASS" https://mail.example.org/iredadmin/api/user/$i@$domain
done

Maybe not the nicest code, but it works smile