|
From: Ken M. <ma...@gm...> - 2021-11-29 21:01:01
|
Hello, My Outlook account has just been given access to a shared mailbox. I've been using mbsync with DavMail successfully with Outlook with the following config, which pulls mail from https://outlook.office.com/mail/inbox : IMAPAccount foo Timeout 120 PipelineDepth 1 Host localhost Port 1143 User ... AuthMechs LOGIN SSLType None IMAPStore foo-remote Account foo Path INBOX MaildirStore foo-local Path ~/Maildir/ Inbox ~/Maildir/foo Channel foo Master :foo-remote: Slave :foo-local: Create Slave Sync All Patterns "INBOX" SyncState * The new shared inbox is at https://outlook.office.com/mail/us...@do... I've been playing around with mbsync for an hour trying to set up a new config that will pull from that mailbox, but I cannot get it to work. Has anyone used mbsync with a shared Outlook mailbox? It's been a LOOOONG time since I had only 1 Google result, but that's all there is for "mbsync" + "shared outlook". Thanks, -k. |
|
From: Oswald B. <osw...@gm...> - 2021-11-30 14:47:17
|
On Mon, Nov 29, 2021 at 12:02:01PM -0800, Ken Mankoff wrote: >I've been playing around with mbsync for an hour trying to set up a new >config that will pull from that mailbox, but I cannot get it to work. >Has anyone used mbsync with a shared Outlook mailbox? > not me, anyway. ^^ for starters, run 'mbsync -Dn -l foo', and pay attention to the NAMESPACE response, which should give clues how to set up Path. next thing then would be verifying that the LIST responses make sense (though you'd need to include a wildcard in Patterns for it to even issue a list command). if you can't get it to work, post the log (or send it to me). |
|
From: Ken M. <ma...@gm...> - 2021-11-30 15:08:40
|
Hi Oswald, On 2021-11-30 at 06:45 -08, Oswald Buddenhagen <osw...@gm...> wrote: > On Mon, Nov 29, 2021 at 12:02:01PM -0800, Ken Mankoff wrote: >> I've been playing around with mbsync for an hour trying to set up a >> new config that will pull from that mailbox, but I cannot get it to >> work. Has anyone used mbsync with a shared Outlook mailbox? >> > not me, anyway. ^^ > > for starters, run 'mbsync -Dn -l foo', and pay attention to the > NAMESPACE response, which should give clues how to set up Path. > next thing then would be verifying that the LIST responses make sense > (though you'd need to include a wildcard in Patterns for it to even > issue a list command). > > if you can't get it to work, post the log (or send it to me). ~ $ mbsync --version isync 1.3.0 I don't see NAMESPACE. ~ $ mbsync -Dn -l foo Channel foo Opening master store foo-remote... Resolving localhost... ok Connecting to localhost (127.0.0.1:1143)... Opening slave store foo-local... * OK [CAPABILITY IMAP4REV1 AUTH=LOGIN MOVE SPECIAL-USE] IMAP4rev1 DavMail 5.4.0-trunk server ready Logging in... *** IMAP Warning *** Password is being sent in the clear >>> 1 LOGIN <user> <pass> 1 OK Authenticated >>> 2 LIST "" INBOX* * LIST (\HasNoChildren) "/" "INBOX" 2 OK LIST completed INBOX >>> 3 LOGOUT * BYE Closing connection 3 OK LOGOUT completed If I change "Patterns INBOX" to "Patterns *", then I get: ~ $ mbsync -Dn -l foo Channel foo Opening master store foo-remote... Resolving localhost... ok Connecting to localhost (127.0.0.1:1143)... Opening slave store foo-local... Maildir warning: ignoring INBOX in /home/user/Maildir/ Maildir error: found subfolder 'mail_2019/archive', but store 'foo-local' does not specify SubFolders style -k. |
|
From: Oswald B. <osw...@gm...> - 2021-11-30 15:33:35
|
On Tue, Nov 30, 2021 at 07:08:26AM -0800, Ken Mankoff wrote: >I don't see NAMESPACE. > well, apparently davmail doesn't have it. not helpful, but whatever. >Opening slave store foo-local... >Maildir warning: ignoring INBOX in /home/user/Maildir/ >Maildir error: found subfolder 'mail_2019/archive', but store 'foo-local' does not specify SubFolders style > you obviously need to resolve these first, the 'how' depending on the folder structure you actually want to achieve. for the purpose of mbsync dumping the imap folder list, you may just create a dummy maildir store (empty folder in /tmp or some such). or you could use an interactive imap client (thunderbird, or whatever) to do the browsing. i suppose one-sided -l commands to address this use case would be a reasonable feature. |
|
From: Oswald B. <os...@us...> - 2022-06-19 14:37:29
|
commit 5d5e07eb63b37dba7c37715c44dcbb4518af5b9b
Author: Oswald Buddenhagen <os...@us...>
Date: Wed May 18 22:40:25 2022 +0200
add --list-stores mode
this is useful for verifying the store configuration, and finding the
right mailbox names.
REFMAIL: YaZC3XUTWjyfjgn+@ugly
NEWS | 2 +
src/Makefile.am | 2 +-
src/config.c | 2 -
src/driver.c | 2 +
src/driver.h | 2 +
src/main.c | 13 +++-
src/main_list.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++++
src/main_p.h | 1 +
src/mbsync.1 | 9 +++
9 files changed, 216 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index aa53a198..27eb2c0b 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ The old locations remain supported.
The reference point for relative local paths in the configuration file
is now the file's containing directory.
+The unfiltered list of mailboxes in each Store can be printed now.
+
[1.4.0]
The 'isync' compatibility wrapper was removed.
diff --git a/src/Makefile.am b/src/Makefile.am
index e7560446..f241db27 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,7 +8,7 @@ mbsync_SOURCES = \
drv_imap.c \
drv_maildir.c \
sync.c sync_state.c \
- main.c main_sync.c
+ main.c main_sync.c main_list.c
noinst_HEADERS = \
common.h config.h socket.h \
driver.h \
diff --git a/src/config.c b/src/config.c
index 880f0271..f932920d 100644
--- a/src/config.c
+++ b/src/config.c
@@ -20,8 +20,6 @@ char FieldDelimiter = ';';
char FieldDelimiter = ':';
#endif
-static store_conf_t *stores;
-
char *
expand_strdup( const char *s, const conffile_t *cfile )
{
diff --git a/src/driver.c b/src/driver.c
index f5f73bae..05bbb9b0 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -7,6 +7,8 @@
#include "driver.h"
+store_conf_t *stores;
+
driver_t *drivers[N_DRIVERS] = { &maildir_driver, &imap_driver };
void
diff --git a/src/driver.h b/src/driver.h
index d7c4e3d8..e810bf1f 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -31,6 +31,8 @@ typedef struct store_conf {
STORE_CONF
} store_conf_t;
+extern store_conf_t *stores;
+
/* For message->flags */
// Keep the MESSAGE_FLAGS in sync (grep that)!
/* The order is according to alphabetical maildir flag sort */
diff --git a/src/main.c b/src/main.c
index 010397eb..0196db3c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,6 +33,7 @@ PACKAGE " " VERSION " - mailbox synchronizer\n"
" " EXE " [flags] {{channel[:box,...]|group} ...|-a}\n"
" -a, --all operate on all defined channels\n"
" -l, --list list mailboxes instead of syncing them\n"
+" -ls, --list-stores raw listing of stores' mailboxes\n"
" -n, --new propagate new messages\n"
" -d, --delete propagate message deletions\n"
" -f, --flags propagate message flag changes\n"
@@ -173,6 +174,8 @@ main( int argc, char **argv )
mvars->all = 1;
} else if (!strcmp( opt, "list" )) {
mvars->list = 1;
+ } else if (!strcmp( opt, "list-stores" )) {
+ mvars->list_stores = 1;
} else if (!strcmp( opt, "help" )) {
usage( 0 );
} else if (!strcmp( opt, "version" )) {
@@ -295,7 +298,10 @@ main( int argc, char **argv )
mvars->all = 1;
break;
case 'l':
- mvars->list = 1;
+ if (*ochar == 's')
+ mvars->list_stores = 1, ochar++;
+ else
+ mvars->list = 1;
break;
case 'c':
if (oind >= argc) {
@@ -468,6 +474,9 @@ main( int argc, char **argv )
if (load_config( config ))
return 1;
- sync_chans( mvars, argv + oind );
+ if (mvars->list_stores)
+ list_stores( mvars, argv + oind );
+ else
+ sync_chans( mvars, argv + oind );
return mvars->ret;
}
diff --git a/src/main_list.c b/src/main_list.c
new file mode 100644
index 00000000..adda4b9a
--- /dev/null
+++ b/src/main_list.c
@@ -0,0 +1,188 @@
+// SPDX-FileCopyrightText: 2022 Oswald Buddenhagen <os...@us...>
+// SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-isync-GPL-exception
+//
+// mbsync - mailbox synchronizer
+//
+
+#include "main_p.h"
+
+typedef struct store_ent {
+ struct store_ent *next;
+ store_conf_t *conf;
+} store_ent_t;
+
+typedef struct {
+ core_vars_t *cvars;
+ store_conf_t *store;
+ driver_t *drv;
+ store_t *ctx;
+ store_ent_t *storeptr;
+ int cben, done;
+} list_vars_t;
+
+static store_ent_t *
+add_store( store_ent_t ***storeapp, store_conf_t *store )
+{
+ store_ent_t *se = nfzalloc( sizeof(*se) );
+ se->conf = store;
+ **storeapp = se;
+ *storeapp = &se->next;
+ return se;
+}
+
+static void do_list_stores( list_vars_t *lvars );
+static void list_next_store( list_vars_t *lvars );
+
+void
+list_stores( core_vars_t *cvars, char **argv )
+{
+ list_vars_t lvars[1];
+ store_ent_t *strs = NULL, **strapp = &strs;
+ store_conf_t *store;
+
+ memset( lvars, 0, sizeof(*lvars) );
+ lvars->cvars = cvars;
+
+ if (!stores) {
+ fputs( "No stores defined.\n", stderr );
+ cvars->ret = 1;
+ return;
+ }
+
+ if (!*argv) { // Implicit --all
+ for (store = stores; store; store = store->next)
+ add_store( &strapp, store );
+ } else {
+ for (; *argv; argv++) {
+ for (store = stores; store; store = store->next) {
+ if (!strcmp( store->name, *argv )) {
+ add_store( &strapp, store );
+ goto gotstr;
+ }
+ }
+ error( "No store named '%s' defined.\n", *argv );
+ cvars->ret = 1;
+ gotstr: ;
+ }
+ }
+ if (cvars->ret)
+ return;
+ lvars->storeptr = strs;
+
+ do_list_stores( lvars );
+ main_loop();
+}
+
+static void
+list_store_bad( void *aux )
+{
+ list_vars_t *lvars = (list_vars_t *)aux;
+
+ lvars->drv->cancel_store( lvars->ctx );
+ lvars->cvars->ret = 1;
+ list_next_store( lvars );
+}
+
+static void
+advance_store( list_vars_t *lvars )
+{
+ store_ent_t *nstr = lvars->storeptr->next;
+ free( lvars->storeptr );
+ lvars->storeptr = nstr;
+}
+
+static void list_store_connected( int sts, void *aux );
+
+static void
+do_list_stores( list_vars_t *lvars )
+{
+ while (lvars->storeptr) {
+ lvars->store = lvars->storeptr->conf;
+ lvars->drv = lvars->store->driver;
+ int st = lvars->drv->get_fail_state( lvars->store );
+ if (st != FAIL_TEMP) {
+ info( "Skipping %sfailed store %s.\n",
+ (st == FAIL_WAIT) ? "temporarily " : "", lvars->store->name );
+ lvars->cvars->ret = 1;
+ goto next;
+ }
+
+ uint dcaps = lvars->drv->get_caps( NULL );
+ store_t *ctx = lvars->drv->alloc_store( lvars->store, "" );
+ if ((DFlags & DEBUG_DRV) || ((DFlags & FORCEASYNC) && !(dcaps & DRV_ASYNC))) {
+ lvars->drv = &proxy_driver;
+ ctx = proxy_alloc_store( ctx, "" );
+ }
+ lvars->ctx = ctx;
+ lvars->drv->set_bad_callback( ctx, list_store_bad, lvars );
+ info( "Opening store %s...\n", lvars->store->name );
+ lvars->cben = lvars->done = 0;
+ lvars->drv->connect_store( lvars->ctx, list_store_connected, lvars );
+ if (!lvars->done) {
+ lvars->cben = 1;
+ return;
+ }
+
+ next:
+ advance_store( lvars );
+ }
+ cleanup_drivers();
+}
+
+static void
+list_next_store( list_vars_t *lvars )
+{
+ if (lvars->cben) {
+ advance_store( lvars );
+ do_list_stores( lvars );
+ }
+}
+
+static void
+list_done_store( list_vars_t *lvars )
+{
+ lvars->done = 1;
+ lvars->drv->free_store( lvars->ctx );
+ list_next_store( lvars );
+}
+
+static void list_store_listed( int sts, string_list_t *boxes, void *aux );
+
+static void
+list_store_connected( int sts, void *aux )
+{
+ list_vars_t *lvars = (list_vars_t *)aux;
+
+ switch (sts) {
+ case DRV_CANCELED:
+ return;
+ case DRV_OK:
+ lvars->drv->list_store( lvars->ctx, LIST_INBOX | LIST_PATH_MAYBE, list_store_listed, lvars );
+ break;
+ default:
+ lvars->cvars->ret = 1;
+ list_done_store( lvars );
+ break;
+ }
+}
+
+static void
+list_store_listed( int sts, string_list_t *boxes, void *aux )
+{
+ list_vars_t *lvars = (list_vars_t *)aux;
+ string_list_t *box;
+
+ switch (sts) {
+ case DRV_CANCELED:
+ return;
+ case DRV_OK:
+ printf( "===== %s:\n", lvars->ctx->conf->name );
+ for (box = boxes; box; box = box->next)
+ puts( box->string );
+ break;
+ default:
+ lvars->cvars->ret = 1;
+ break;
+ }
+ list_done_store( lvars );
+}
diff --git a/src/main_p.h b/src/main_p.h
index 317367a5..75f619c1 100644
--- a/src/main_p.h
+++ b/src/main_p.h
@@ -20,5 +20,6 @@ typedef struct {
} core_vars_t;
void sync_chans( core_vars_t *cvars, char **argv );
+void list_stores( core_vars_t *cvars, char **argv );
#endif
diff --git a/src/mbsync.1 b/src/mbsync.1
index 403b2ce7..ee54129a 100644
--- a/src/mbsync.1
+++ b/src/mbsync.1
@@ -11,6 +11,8 @@ mbsync - synchronize IMAP4 and Maildir mailboxes
.
.SH SYNOPSIS
\fBmbsync\fR [\fIoptions\fR ...] {{\fIchannel\fR[\fB:\fIbox\fR[{\fB,\fR|\fB\\n\fR}...]]|\fIgroup\fR} ...|\fB-a\fR}
+.br
+\fBmbsync\fR --list-stores [\fIoptions\fR ...] [\fIstore\fR} ...]
.
.SH DESCRIPTION
\fBmbsync\fR is a command line application which synchronizes mailboxes;
@@ -43,6 +45,13 @@ command line are ignored.
Don't synchronize anything, but list all mailboxes in the selected Channels
and exit.
.TP
+\fB-ls\fR, \fB--list-stores\fR
+Don't synchronize anything, but list all mailboxes in the selected Stores
+and exit.
+If no Stores are specified, all configured ones are listed.
+These are raw Store contents, not filtered by any Channel's \fBPatterns\fR.
+This option may be used to verify each Store's configuration.
+.TP
\fB-C\fR[\fBf\fR][\fBn\fR], \fB--create\fR[\fB-far\fR|\fB-near\fR]
Override any \fBCreate\fR options from the config file. See below.
.TP
|
|
From: Ken M. <ma...@gm...> - 2021-11-30 16:50:12
|
Hi Oswald, Hi Oswald, On 2021-11-30 at 07:27 -08, Oswald Buddenhagen <osw...@gm...> wrote: > On Tue, Nov 30, 2021 at 07:08:26AM -0800, Ken Mankoff wrote: >>Opening slave store foo-local... >>Maildir warning: ignoring INBOX in /home/user/Maildir/ >>Maildir error: found subfolder 'mail_2019/archive', but store 'foo-local' does not specify SubFolders style >> > > you obviously need to resolve these first, the 'how' depending on the > folder structure you actually want to achieve. I don't want subfolders. I have Maildir/Inbox1 Maildir/Inbox2 Maildir/Archive_2019 Maildir/Archive_2020 Maildir/Archive I'd like to add Maildir/Inbox3 that is linked to this new mailbox. But I may be misunderstanding what subfolders are. It may be that the issue is on the remote, I can pull the inbox from https://outlook.office.com/mail/inbox But the "Shared folder" is at https://outlook.office.com/mail/us...@do.../inbox Which sure looks like a subfolder, with a weirdly-named top folder, "us...@do...". -k. |
|
From: Oswald B. <osw...@gm...> - 2021-11-30 16:40:00
|
On Tue, Nov 30, 2021 at 08:16:59AM -0800, Ken Mankoff wrote: >On 2021-11-30 at 07:27 -08, Oswald Buddenhagen ><osw...@gm...> wrote: >> On Tue, Nov 30, 2021 at 07:08:26AM -0800, Ken Mankoff wrote: >>>Opening slave store foo-local... >>>Maildir warning: ignoring INBOX in /home/user/Maildir/ >>>Maildir error: found subfolder 'mail_2019/archive', but store 'foo-local' does not specify SubFolders style >>> >> >> you obviously need to resolve these first, the 'how' depending on the >> folder structure you actually want to achieve. > >I don't want subfolders. I have > >Maildir/Inbox1 >Maildir/Inbox2 >Maildir/Archive_2019 >Maildir/Archive_2020 >Maildir/Archive > well, but the fact is that you *do* have a subfolder in one of those boxes. you need to figure that out. >I'd like to add > >Maildir/Inbox3 that is linked to this new mailbox. > i see. this is "weird", but in principle reasonable. >It may be that the issue is on the remote, I can pull the inbox from > >https://outlook.office.com/mail/inbox > >But the "Shared folder" is at > >https://outlook.office.com/mail/us...@do.../inbox > >Which sure looks like a subfolder, with a weirdly-named top folder, "us...@do...". > yeah, but that's not what mbsync complains about. the problem is that i don't know how that shared folder url is mapped to an actual imap mailbox name. this depends on your davmail configuration. once you have figured that out, something like that may work: Channel foo Master :foo-remote:<shared-box> # INBOX implied; you could also use the actual name if you don't map # Inbox in the store config. Slave :foo-local: # no Patterns; this is a single box mapping. |
|
From: Ken M. <ma...@gm...> - 2021-11-30 17:44:28
|
Hi Oswald, Thank you so much for the continued help. On 2021-11-30 at 08:39 -08, Oswald Buddenhagen <osw...@gm...> wrote: > well, but the fact is that you *do* have a subfolder in one of those > boxes. you need to figure that out. You're right. There was somehow a misplaced folder. I removed it. That error message is no more. >> It may be that the issue is on the remote, I can pull the inbox from >> >> https://outlook.office.com/mail/inbox >> >> But the "Shared folder" is at >> >> https://outlook.office.com/mail/us...@do.../inbox >> >> Which sure looks like a subfolder, with a weirdly-named top folder, >> "us...@do...". >> > yeah, but that's not what mbsync complains about. New complaint :). Using your suggested config as a guide, I now have: IMAPAccount DV Timeout 120 PipelineDepth 1 Host localhost Port 1143 AuthMechs LOGIN SSLType None IMAPStore DV-remote Account DV Path "us...@do.../inbox" MaildirStore DV-local Path ~/Maildir/ Inbox ~/Maildir/dataverse Channel DV Master ":DV-remote:" Slave ":DV-local:dataverse" Create Slave Sync All SyncState * I've also tried with moving info from DV-remote Path to Channel Master. I'm clearly just moving strings around here and guessing. But the appears-to-work with "-Dn -l" is the same in both cases, and the error without "-Dn -l" is the same in both cases. IMAPStore DV-remote Account DV # Path "us...@do.../inbox" # NO PATH MaildirStore DV-local Path ~/Maildir/ Inbox ~/Maildir/dataverse Channel DV # Master ":DV-remote:" Master ":DV-remote:geu...@ge.../inbox" Slave ":DV-local:dataverse" Create Slave Sync All SyncState * It looks (to my untrained eye) like things are working when I run with "-Dn -l": $ mbsync -Dn -l DV Channel DV Opening master store DV-remote... Resolving localhost... ok Connecting to localhost (127.0.0.1:1143)... Opening slave store DV-local... * OK [CAPABILITY IMAP4REV1 AUTH=LOGIN MOVE SPECIAL-USE] IMAP4rev1 DavMail 5.4.0-trunk server ready Logging in... >>> 1 LOGIN <user> <pass> 1 OK Authenticated us...@do.../inbox <=> dataverse >>> 2 LOGOUT * BYE Closing connection 2 OK LOGOUT completed But when I run without "-Dn -l", then a new error: $ mbsync DV C: 0/1 B: 0/1 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0 IMAP error: mailbox name us...@do.../inbox contains server's hierarchy delimiter Error: channel DV: master us...@do.../inbox cannot be opened. C: 1/1 B: 1/1 M: +0/0 *0/0 #0/0 S: +0/0 *0/0 #0/0 -k. |
|
From: Oswald B. <osw...@gm...> - 2021-11-30 20:03:22
|
On Tue, Nov 30, 2021 at 09:44:16AM -0800, Ken Mankoff wrote: >It looks (to my untrained eye) like things are working when I run with >"-Dn -l": > only because you're telling it exactly what to say. if you use a Pattern with a wildcard, it will blow up. >IMAP error: mailbox name us...@do.../inbox contains server's hierarchy delimiter >Error: channel DV: master us...@do.../inbox cannot be opened. > huh, you found a (minor) bug. you can sidestep it with PathDelimiter "/". (alternatively, "#", if that slash *really* isn't a delimiter.) you can also try Path "us...@do.../" and use "" (== INBOX) for the master side box - it's presumably case-insensitive. |