1

Topic: Need to import_users.py

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.3.2
- Deployed with iRedMail Easy or the downloadable installer?
- Linux/BSD distribution name and version: Centos 8
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- 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.
====

sudo python2 import_users.py /opt/users.list

Traceback (most recent call last):
  File "import_users.py", line 94, in <module>
    from libs import iredutils
  File "/home/user/iRedAdmin-Pro-SQL-4.6/tools/../libs/iredutils.py", line 92
    def is_auth_email(s) -> bool:
                         ^
SyntaxError: invalid syntax

this is the syntax i'm using: user@domain.mx, password, 2048, User Name,

do i need to change something?

----

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

2

Re: Need to import_users.py

The latest iRedAdmin-Pro now requires Python 3, please run it with command "python3", not "python2".

3

Re: Need to import_users.py

ZhangHuangbin wrote:

The latest iRedAdmin-Pro now requires Python 3, please run it with command "python3", not "python2".

i got this with python3 :

sudo python3 import_users.py /opt/users.list
Traceback (most recent call last):
  File "import_users.py", line 94, in <module>
    from libs import iredutils
  File "/home/user/iRedAdmin-Pro-SQL-4.6/tools/../libs/iredutils.py", line 20, in <module>
    import settings
ModuleNotFoundError: No module named 'settings'

4

Re: Need to import_users.py

It's pretty clear that you're running this script under /home/user/iRedAdmin-Pro-SQL-4.6/, but it doesn't contain config file "settings.py".
Please run the one under /opt/www/iredadmin/tools/ instead.

5

Re: Need to import_users.py

ZhangHuangbin wrote:

It's pretty clear that you're running this script under /home/user/iRedAdmin-Pro-SQL-4.6/, but it doesn't contain config file "settings.py".
Please run the one under /opt/www/iredadmin/tools/ instead.

I have this error now:

[user@mail ~]$ cd /opt/www/iredadmin/tools/
[user@mail tools]$ sudo python3 import_users.py /opt/users.list
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib64/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib64/python3.6/http/client.py", line 1254, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1300, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1249, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1036, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 974, in send
    self.connect()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 181, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f7efcea8f98>: Failed to establish a new connection: [Errno -2] Name or service not known

6

Re: Need to import_users.py

Did you configure the "api_endpoint =" parameter in "import_users.py"?
Please read the comment lines at the beginning of "import_users.py" file, it contains detailed instruction.

7

Re: Need to import_users.py

ZhangHuangbin wrote:

Did you configure the "api_endpoint =" parameter in "import_users.py"?
Please read the comment lines at the beginning of "import_users.py" file, it contains detailed instruction.

Sorry, i was using de incorrect file, the file import_users.py that i was using is at the location /home/user/iRedAdmin-Pro-SQL-4.6/tools/

now i see there is another file import_users.py in /opt/www/iredadmin/tools/, i already edited with all info, now i get Login failed, im using postmaster wich is the master admin, now what im doing wrong?

8

Re: Need to import_users.py

j.sotelo wrote:

now i see there is another file import_users.py in /opt/www/iredadmin/tools/, i already edited with all info, now i get Login failed, im using postmaster wich is the master admin, now what im doing wrong?

What's the error now?

9

Re: Need to import_users.py

ZhangHuangbin wrote:
j.sotelo wrote:

now i see there is another file import_users.py in /opt/www/iredadmin/tools/, i already edited with all info, now i get Login failed, im using postmaster wich is the master admin, now what im doing wrong?

What's the error now?


no error, only get: Login failed
That's all.

10

Re: Need to import_users.py

Login failed means incorrect username or password. please double check.

11

Re: Need to import_users.py

ZhangHuangbin wrote:

Login failed means incorrect username or password. please double check.

I was using an ip in System Settings, i remove the ips in the "RESTful API is accessible only from specified IP addresses or networks"

now, i get this error:

<<< ERROR >>> line has invalid user email address:
b'test@domain.com, PassWord,2048, Test,'

12

Re: Need to import_users.py

It's a bug of the "import_users.py", i will fix it later today and come back later.  Stay tuned.
Sorry about this trouble.

13

Re: Need to import_users.py

ZhangHuangbin wrote:

It's a bug of the "import_users.py", i will fix it later today and come back later.  Stay tuned.
Sorry about this trouble.

Hi there, I would like to know if you had any news about this bug?

14

Re: Need to import_users.py

Oops, partly fixed but forgot to finish it. I will try to finish it in 2 days. sad
Feel free to remind me if i'm too lazy.

15

Re: Need to import_users.py

Sorry about the late reply. Here's the patch to fix the issue in tools/import_users.py:

diff --git a/tools/import_users.py b/tools/import_users.py
index 23909ea8..1160f1f0 100644
--- a/tools/import_users.py
+++ b/tools/import_users.py
@@ -149,9 +149,8 @@ cookies = r.cookies
 f = open(file, 'rb')
 
 for line in f.readlines():
-    line = line.strip()
-
-    fields = line.split(b',')
+    line = iredutils.bytes2str(line.strip())
+    fields = line.split(',')
 
     try:
         d = {}

If you're not familiar with patch, contact us to get a patched version.
https://www.iredmail.org/contact.html

16

Re: Need to import_users.py

Hello, I have a similar problem, but I checked the lines that you indicate and they are the same, the message is the same
/opt/www/iredadmin/tools# python3 import_users.py /home/manticore/extracto.csv
<<< ERROR >>> line has invalid user email address: abigailruiz@fundacionlms.mx
Line: abigailruiz@fundacionlms.mx,6SDRC@=,,Abigail Maria Cecilia Ruiz Padilla

17

Re: Need to import_users.py

manticoremx wrote:

Hello, I have a similar problem, but I checked the lines that you indicate and they are the same, the message is the same
/opt/www/iredadmin/tools# python3 import_users.py /home/manticore/extracto.csv
<<< ERROR >>> line has invalid user email address: abigailruiz@fundacionlms.mx
Line: abigailruiz@fundacionlms.mx,6SDRC@=,,Abigail Maria Cecilia Ruiz Padilla

Sorry forgot to add that I have the PRO version iRedAdmin-Pro-LDAP-5.2

18

Re: Need to import_users.py

manticoremx wrote:

<<< ERROR >>> line has invalid user email address: abigailruiz@fundacionlms.mx

Please double check the line in your csv file.