doc:appunti:linux:sa:imap
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
doc:appunti:linux:sa:imap [2021/03/08 18:18] – [offlineimap] niccolo | doc:appunti:linux:sa:imap [2024/03/20 17:48] – [IMAP protocol] niccolo | ||
---|---|---|---|
Line 41: | Line 41: | ||
a6 OK FETCH completed. | a6 OK FETCH completed. | ||
a7 LOGOUT | a7 LOGOUT | ||
+ | </ | ||
+ | |||
+ | Some IMAP servers present all the folders as subfolders of the INBOX: | ||
+ | |||
+ | < | ||
+ | a3 LIST "" | ||
+ | * LIST (\HasNoChildren) | ||
+ | * LIST (\HasNoChildren) | ||
+ | * LIST (\HasNoChildren) | ||
+ | * LIST (\Marked \HasChildren) " | ||
+ | a4 CREATE INBOX.Archive | ||
+ | </ | ||
+ | |||
+ | For other IMAP servers, the folders are outside the INBOX: | ||
+ | |||
+ | < | ||
+ | a3 LIST "" | ||
+ | * LIST (\HasNoChildren) | ||
+ | * LIST (\HasNoChildren \Drafts) | ||
+ | * LIST (\HasNoChildren \UnMarked \Sent) " | ||
+ | * LIST (\HasNoChildren \Trash) | ||
+ | * LIST (\HasNoChildren) | ||
+ | a4 CREATE Archive | ||
</ | </ | ||
Line 49: | Line 72: | ||
Sincronizza una cartella su server **IMAP remoto** con una **Maildir locale** oppure un altro **server IMAP**. Sembra il programma più flessibile e semplice da utilizzare rispetto a **isync**, **mailsync**, | Sincronizza una cartella su server **IMAP remoto** con una **Maildir locale** oppure un altro **server IMAP**. Sembra il programma più flessibile e semplice da utilizzare rispetto a **isync**, **mailsync**, | ||
- | La versione | + | **ATTENZIONE** :!: Le versioni |
+ | |||
+ | **ATTENZIONE** :!: La versione | ||
- | **ATTENZIONE** :!: Il programma | + | **ATTENZIONE** :!: Il programma |
Pertanto, prima di iniziare la sincronizzazione, | Pertanto, prima di iniziare la sincronizzazione, | ||
- | === Da IMAP a Maildir === | + | === Esempio #1: da IMAP a Maildir === |
Il primo esempio riguarda una migrazione da repository **IMAP remoto** a **Maildir locale**. Prepariamo il file di configurazione **offlineimap-imap-maildir.conf**: | Il primo esempio riguarda una migrazione da repository **IMAP remoto** a **Maildir locale**. Prepariamo il file di configurazione **offlineimap-imap-maildir.conf**: | ||
Line 75: | Line 100: | ||
nametrans = lambda foldername: re.sub(' | nametrans = lambda foldername: re.sub(' | ||
remotehost = mail.example.org | remotehost = mail.example.org | ||
- | remoteuser = username1 | + | remoteuser = username |
remotepass = MySecret | remotepass = MySecret | ||
createfolders = False | createfolders = False | ||
- | sslcacertfile = / | + | sslcacertfile = / |
+ | ssl_version = tls1_2 | ||
+ | # If you don't want IMAPS on port 993, you can use STARTTLS on port 143. | ||
+ | #ssl = no | ||
+ | #starttls = yes | ||
[Repository Localhost] | [Repository Localhost] | ||
Line 84: | Line 113: | ||
localfolders = / | localfolders = / | ||
</ | </ | ||
+ | |||
+ | Per impostazione predefinita offlineimap tenta una connessione **SSL** su porta **993/ | ||
+ | |||
+ | < | ||
+ | offlineimap.error.OfflineImapError: | ||
+ | You must configure at least something, otherwise having SSL helps nothing. | ||
+ | </ | ||
+ | |||
+ | Per vedere quale Certification Authority deve essere usata è necessario recuperare il certificato SSL dal server remoto, ad esempio con il comando: | ||
+ | |||
+ | < | ||
+ | openssl s_client -showcerts -connect mail.example.org: | ||
+ | </ | ||
+ | |||
+ | Quindi si ispeziona la **certificate chain** alla ricerca di **O**rganization e **C**ommon **N**ame con valori del tipo: | ||
+ | |||
+ | * O = Actalis S.p.A., CN = Actalis Organization Validated Server CA G3 | ||
+ | * O = Let's Encrypt, CN = R3 | ||
+ | |||
+ | Avendo installato il pacchetto **ca-certificates**, | ||
+ | |||
+ | < | ||
+ | [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c: | ||
+ | </ | ||
+ | |||
+ | Questo significa che il server utilizza una versione debole di SSL, vulnerabile ad attacchi del tipo //Factoring RSA Export Keys// poiché usa una chiave Diffie-Hellman più corta di 768 byte. In questo caso, se non possiamo correggere il server, è necessario aggiungere l' | ||
+ | |||
+ | Se si desidera utilizzare una connessione con STARTTLS su porta 143, è necessario aggiungere le opzioni '' | ||
Si esegue il programma in modalità **%%--info%%**, | Si esegue il programma in modalità **%%--info%%**, | ||
Line 89: | Line 146: | ||
< | < | ||
offlineimap --dry-run --info -c ./ | offlineimap --dry-run --info -c ./ | ||
+ | </ | ||
+ | |||
+ | Nell' | ||
+ | |||
+ | < | ||
... | ... | ||
Remote repository ' | Remote repository ' | ||
Line 111: | Line 173: | ||
* Ogni sottocartella deve avere il punto come prefisso del nome (directory nascosta Unix). | * Ogni sottocartella deve avere il punto come prefisso del nome (directory nascosta Unix). | ||
- | === Da IMAP a IMAP === | + | Vengono create le cartelle **$HOME/ |
- | Creare un file di configurazione **'' | + | === Esempio #2: da IMAP a IMAP === |
+ | |||
+ | In questo esempio di effettua la sincronizzazione fra due server IMAP, quindi senza fare accesso diretto al filesystem. Questo il file di configurazione **offlineimap-imap-imap.conf**: | ||
< | < | ||
Line 121: | Line 185: | ||
[Account Test] | [Account Test] | ||
- | localrepository | + | remoterepository |
- | remoterepository | + | localrepository |
- | [Repository | + | [Repository |
- | type = Maildir | + | type = IMAP |
- | localfolders = / | + | # Strip the " |
- | # If the remote IMAP is a Lotus Domino, remove the **'' | + | # 'INBOX' |
- | #nametrans = lambda foldername: re.sub(' | + | # 'INBOX.Trash' => ' |
+ | # ' | ||
+ | nametrans = lambda foldername: re.sub(r'^INBOX\.', '', | ||
+ | remotehost = mail1.example.org | ||
+ | remoteuser = username1 | ||
+ | remotepass = MySecret1 | ||
+ | createfolders = False | ||
+ | sslcacertfile = / | ||
- | [Repository | + | [Repository |
type = IMAP | type = IMAP | ||
- | # Remote server is Courier-IMAP, | + | remotehost = mail2.example.org |
- | nametrans = lambda foldername: re.sub(' | + | remoteuser = username2 |
- | # Remote server is Lotus Domino, add an " | + | remotepass = MySecret2 |
- | #nametrans = lambda foldername: ' | + | sslcacertfile = / |
- | remotehost = mail.host1.it | + | |
- | remoteuser = user1 | + | |
- | remotepass = password1 | + | |
</ | </ | ||
- | quindi eseguire | + | Si esegue il programma in modalità **%%--info%%**: |
< | < | ||
- | offlineimap -1 -c offlineimap.conf -d imap, | + | offlineimap --dry-run --info -c ./ |
+ | </ | ||
+ | |||
+ | Verifichiamo l' | ||
+ | |||
+ | < | ||
+ | Remote repository ' | ||
+ | ... | ||
+ | Folderlist: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Local repository ' | ||
+ | ... | ||
+ | Folderlist: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Si capisce che i due server IMAP utilizzano una struttura diversa: il primo ha il prefisso '' | ||
+ | |||
+ | === Sincronizzazione === | ||
+ | |||
+ | La sincronizzazione avviene semplicemente eseguendo il comando con l' | ||
+ | |||
+ | < | ||
+ | offlineimap -1 -c offlineimap-imap-imap.conf -d imap, | ||
</ | </ | ||
* Lo stato della sincronizzazione viene scritto in **'' | * Lo stato della sincronizzazione viene scritto in **'' | ||
* La '' | * La '' | ||
- | * L' | + | * Potrebbe essere necessario specificare l' |
- | * L' | + | |
- | * La versione | + | === Soluzione problemi === |
- | * Con la versione **6.5.4** i messaggi importati hanno **mode 0755**, usare la versione **6.5.5**. | + | |
+ | Vedere | ||
==== isync ==== | ==== isync ==== |
doc/appunti/linux/sa/imap.txt · Last modified: 2024/03/21 12:56 by niccolo