diff --git a/LOG_imapsync/2024_08_29_11_09_24_721_serfling@itdata-gera.de_archiv@archiv.trendsetzer.eu.txt b/LOG_imapsync/2024_08_29_11_09_24_721_serfling@itdata-gera.de_archiv@archiv.trendsetzer.eu.txt new file mode 100644 index 0000000..2243768 --- /dev/null +++ b/LOG_imapsync/2024_08_29_11_09_24_721_serfling@itdata-gera.de_archiv@archiv.trendsetzer.eu.txt @@ -0,0 +1,86 @@ +Here is imapsync 2.229 on host imapsync, a linux system with 0.1/1.9 free GiB of RAM, 98.08% used by processes. +with Perl 5.36.0 and Mail::IMAPClient 3.43 +Transfer started at Donnerstag 29 August 2024-08-29 11:09:24 +0200 CEST +PID is 169155 my PPID is 169154 +Log file is LOG_imapsync/2024_08_29_11_09_24_721_serfling@itdata-gera.de_archiv@archiv.trendsetzer.eu.txt ( to change it, use --logfile path ; or use --nolog to turn off logging ) +Load is 0.55 0.44 0.58 2/511 on 1 cores +Current directory is /root/IMAP-Sync +Real user id is root (uid 0) +Effective user id is root (euid 0) +$RCSfile: imapsync,v $ $Revision: 2.229 $ $Date: 2022/09/14 18:08:24 $ +Command line used, run by /usr/bin/perl: +/usr/bin/imapsync --host1 mail.itdata-gera.de --user1 serfling@itdata-gera.de --password1 MASKED --host2 imap-sync-front-1 --user2 archiv@archiv.trendsetzer.eu --port2 143 --password2 MASKED +Temp directory is /tmp ( to change it use --tmpdir dirpath ) +kill -QUIT 169155 # special behavior: call to sub catch_exit +kill -TERM 169155 # special behavior: call to sub catch_exit +kill -INT 169155 # special behavior: call to sub catch_reconnect +kill -HUP 169155 # special behavior: call to sub catch_print +kill -USR1 169155 # special behavior: call to sub toggle_sleep +File /tmp/imapsync.pid does not exist +PID file is /tmp/imapsync.pid ( to change it, use --pidfile filepath ; to avoid it use --pidfile "" ) +Writing my PID 169155 in /tmp/imapsync.pid +Writing also my logfile name in /tmp/imapsync.pid : LOG_imapsync/2024_08_29_11_09_24_721_serfling@itdata-gera.de_archiv@archiv.trendsetzer.eu.txt +Modules version list ( use --no-modulesversion to turn off printing this Perl modules list ): +Authen::NTLM 1.09 +CGI 4.66 +Compress::Zlib 2.213 +Crypt::OpenSSL::RSA 0.33 +Data::Uniqid 0.12 +Digest::HMAC_MD5 1.04 +Digest::HMAC_SHA1 1.04 +Digest::MD5 2.58 +Encode 3.21 +Encode::IMAPUTF7 1.05 +File::Copy::Recursive 0.45 +File::Spec 3.84 +Getopt::Long 2.52 +HTML::Entities 3.81 +IO::Socket 1.55 +IO::Socket::INET 1.55 +IO::Socket::INET6 2.73 +IO::Socket::IP 0.41 +IO::Socket::SSL 2.088 +IO::Tee 0.65 +JSON 4.10 +JSON::WebToken 0.10 +LWP 6.77 +MIME::Base64 3.16 +Mail::IMAPClient 3.43 +Net::Ping 2.74 +Net::SSLeay 1.92 +Term::ReadKey 2.38 +Test::MockObject 1.20200122 +Time::HiRes 1.977 +URI::Escape 5.17 +Unicode::String 2.10 + +Info: will resync flags for already transferred messages. Use --noresyncflags to not resync flags. +Host1: probing ssl on port 993 ( use --nosslcheck to avoid this ssl probe ) +Host1: sslcheck detected open ssl port 993 so turning ssl on (use --nossl1 --notls1 to turn off SSL and TLS wizardry) +SSL debug mode level is --debugssl 1 (can be set from 0 meaning no debug to 4 meaning max debug) +Host1: SSL default mode is like --sslargs1 "SSL_verify_mode=0", meaning for host1 SSL_VERIFY_NONE, ie, do not check the server certificate. +Host1: Use --sslargs1 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the server certificate. of host1 +Info: turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1. +Host1: will try to use LOGIN authentication on host1 +Host2: will try to use LOGIN authentication on host2 +Host1: imap connection timeout is 120 seconds +Host2: imap connection timeout is 120 seconds +Host1: imap connection keepalive is on on host1. Use --nokeepalive1 to disable it. +Host2: imap connection keepalive is on on host2. Use --nokeepalive2 to disable it. +Host1: IMAP server [mail.itdata-gera.de] port [993] user [serfling@itdata-gera.de] +Host2: IMAP server [imap-sync-front-1] port [143] user [archiv@archiv.trendsetzer.eu] +Host1: connecting and login on host1 [mail.itdata-gera.de] port [993] with user [serfling@itdata-gera.de] +Host1 IP address: 49.13.56.197 Local IP address: 180.1.1.164 +Host1 banner: * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN] Dovecot ready. +Host1 capability before authentication: IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN AUTH +Host1: mail.itdata-gera.de says it has CAPABILITY for AUTHENTICATE LOGIN +Host1: success login on [mail.itdata-gera.de] with user [serfling@itdata-gera.de] auth [LOGIN] or [LOGIN] +Host2: connecting and login on host2 [imap-sync-front-1] port [143] with user [archiv@archiv.trendsetzer.eu] +Host2 failure: can not open imap connection on host2 [imap-sync-front-1] with user [archiv@archiv.trendsetzer.eu]: Unable to connect to imap-sync-front-1: Invalid argument +++++ Listing 1 errors encountered during the sync ( avoid this listing with --noerrorsdump ). +Err 1/1: Host2 failure: can not open imap connection on host2 [imap-sync-front-1] with user [archiv@archiv.trendsetzer.eu]: Unable to connect to imap-sync-front-1: Invalid argument +The most frequent error is ERR_CONNECTION_FAILURE_HOST2. Check that host1 imap-sync-front-1 on port 143 is the right IMAP server to be contacted for your mailbox. +Exiting with return value 102 (EXIT_CONNECTION_FAILURE_HOST2) 1/50 nb_errors/max_errors PID 169155 +Removing pidfile /tmp/imapsync.pid +Disconnecting from host1 mail.itdata-gera.de user1 serfling@itdata-gera.de +Log file is LOG_imapsync/2024_08_29_11_09_24_721_serfling@itdata-gera.de_archiv@archiv.trendsetzer.eu.txt ( to change it, use --logfile filepath ; or use --nolog to turn off logging ) diff --git a/docker-compose.yml b/docker-compose.yml index e3c45ae..3c99eec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -150,6 +150,21 @@ services: depends_on: - front + imapsync: + build: + dockerfile: imapsync-dockerfile + container_name: imapsync + restart: always + logging: + driver: journald + options: + tag: imapsync + networks: + - default + depends_on: + - front + + networks: default: driver: bridge diff --git a/imapsync-dockerfile b/imapsync-dockerfile index 55796a7..25fd9bc 100644 --- a/imapsync-dockerfile +++ b/imapsync-dockerfile @@ -3,12 +3,19 @@ FROM debian:latest RUN apt update RUN apt upgrade -y RUN apt install -y git make gcc -RUN apt install -y apt-file cpanminus libc6-dev libssl-dev python3 python3-pip python3-csv +RUN apt install -y apt-file cpanminus libc6-dev libssl-dev python3 python3-pip RUN apt install -y libperl-dev zlib1g-dev libnet-ssleay-perl -RUN cpanm App::cpanminus Authen::NTLM CGI Compress::Zlib Crypt::OpenSSL::RSA Data::Dumper Data::Uniqid Dist::CheckConflicts Encode Encode::IMAPUTF7 File::Copy::Recursive File::Tail IO::Socket::INET IO::Socket::INET6 IO::Socket::SSL IO::Tee JSON JSON::WebToken LWP::UserAgent Mail::IMAPClient Module::ScanDeps PAR::Packer Pod::Usage Readonly Regexp::Common Sys::MemInfo Term::ReadKey Test::MockObject Test::More Test::Pod Unicode::String -RUN cd /usr/local/src +RUN cpanm App::cpanminus Authen::NTLM CGI Compress::Zlib Crypt::OpenSSL::RSA Data::Dumper Data::Uniqid Dist::CheckConflicts Encode Encode::IMAPUTF7 File::Copy::Recursive File::Tail IO::Socket::INET IO::Socket::INET6 IO::Socket::SSL IO::Tee JSON JSON::WebToken LWP::UserAgent Mail::IMAPClient Module::ScanDeps PAR::Packer Pod::Usage Readonly Regexp::Common Sys::MemInfo Term::ReadKey Test::MockObject Test::More Test::Pod Unicode::String; exit 0 +RUN apt install -y libproc-processtable-perl python3-requests +WORKDIR /usr/local/src +RUN echo PWD RUN git clone https://github.com/imapsync/imapsync.git -RUN cd imapsync +WORKDIR ./imapsync RUN make install +RUN mkdir /app +WORKDIR /app/ +RUN git clone https://gitlab.stines.de/sebastian.serfling/IMAP-Sync.git . +CMD ["/bin/bash"] + #RUN impasync-script \ No newline at end of file diff --git a/imapsync.py b/imapsync.py index 80d8682..b55c579 100644 --- a/imapsync.py +++ b/imapsync.py @@ -3,11 +3,12 @@ import csv import os import requests import socket +import subprocess from pathlib import Path csvfile = Path("user.csv") -host = "127.0.0.1" +host = "front" port = 993 @@ -35,14 +36,27 @@ except FileNotFoundError: rows = [] with open(csvfile, mode='r', newline='') as file: reader = csv.reader(file, delimiter=";") + next(reader) for row in reader: rows.append(row) for row in rows: - print(len(rows)) - print(row[0]) - print(row[1]) - - + username = row[0] + password = row[1] + domain = row[2] + # Erstellen einer Liste für den Befehl und die Argumente + command = [ + "imapsync", + "--host1", domain, + "--user1", username, + "--password1", password, + "--host2", "front", + "--user2", "archiv@archiv.trendsetzer.eu", + "--port2","143", + "--password2", "S8jZT7Ke3gdzxV0QfsB19R1bNwR716M6yUJQ4az9Kr8EK" + # "--prefix2", f"Archiv/{username}/", # Verwende dynamisch den username im Zielordner + # "--regextrans2", "s/^(.*)$/\\${1}/", + ] + subprocess.run(command) # CSV laden # User in CSV kontrollieren ob vorhanden -> User anlegen diff --git a/mailu.env b/mailu.env index 2704991..1b651d9 100644 --- a/mailu.env +++ b/mailu.env @@ -15,10 +15,10 @@ SECRET_KEY=YZ6BKHDTZRSIZ4HT SUBNET=192.168.203.0/24 # Main mail domain -DOMAIN=test.de +DOMAIN=archiv.trendsetzer.eu # Hostnames for this server, separated with commas -HOSTNAMES=mail.test.de +HOSTNAMES=archiv.trendsetzer.eu # Postmaster local part (will append the main mail domain) POSTMASTER=admin @@ -43,7 +43,7 @@ DISABLE_STATISTICS=True ADMIN=true # Choose which webmail to run if any (values: roundcube, snappymail, none). To enable this feature, recreate the docker-compose.yml file via setup. -WEBMAIL=roundcube +WEBMAIL=snappymail # Expose the API interface (value: true, false) API=true @@ -104,7 +104,7 @@ COMPRESSION_LEVEL= # IMAP full-text search is enabled by default. # Set the following variable to off in order to disable the feature # or a comma separated list of language codes to support -FULL_TEXT_SEARCH=en +FULL_TEXT_SEARCH=de ################################### # Web settings @@ -126,7 +126,7 @@ WEB_API=/api SITENAME=Mailu # Linked Website URL -WEBSITE=https://mailu.io +#WEBSITE=https://mailu.io diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/user.csv b/user.csv index f65585c..ebbdbc4 100644 --- a/user.csv +++ b/user.csv @@ -1 +1,2 @@ -user1;aljksndnlajksnj \ No newline at end of file +Username;Password;Domain +serfling@itdata-gera.de;xPElLoyD,94,#;mail.itdata-gera.de \ No newline at end of file