Skip to content

Commit

Permalink
Fix delivery to Exchange IMAP
Browse files Browse the repository at this point in the history
  • Loading branch information
filippz committed Mar 22, 2019
1 parent 4268e46 commit 6c3ea12
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions deliver-imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ deliver_imap_deliver(struct deliver_ctx *dctx, struct actitem *ti)
*/
count_lines(m, &total, &body);
maillen = m->size + total - 1;
if (fdata.capa & IMAP_CAPA_EXCHANGE) {
log_debug2("%s: reducing size by 1", a->name);
maillen--;
}
if (fdata.capa & IMAP_CAPA_XYZZY) {
log_debug2("%s: adjusting size: actual %zu", a->name, maillen);
maillen = m->size;
Expand Down
1 change: 1 addition & 0 deletions fetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ struct fetch_imap_mail {
#define IMAP_CAPA_STARTTLS 0x4
#define IMAP_CAPA_NOSPACE 0x8
#define IMAP_CAPA_GMEXT 0x10
#define IMAP_CAPA_EXCHANGE 0x20

/* fetch-maildir.c */
extern struct fetch fetch_maildir;
Expand Down
7 changes: 6 additions & 1 deletion imap-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ imap_state_connected(struct account *a, struct fetch_ctx *fctx)
return (FETCH_ERROR);
}

data->capa = 0;
if (strstr(line, "Exchange") != NULL) {
log_debug2("%s: Exchange detected", a->name);
data->capa |= IMAP_CAPA_EXCHANGE;
}

if (imap_putln(a, "%u CAPABILITY", ++data->tag) != 0)
return (FETCH_ERROR);
fctx->state = imap_state_capability1;
Expand Down Expand Up @@ -397,7 +403,6 @@ imap_state_capability1(struct account *a, struct fetch_ctx *fctx)
return (FETCH_ERROR);
}

data->capa = 0;
if (strstr(line, "AUTH=CRAM-MD5") != NULL)
data->capa |= IMAP_CAPA_AUTH_CRAM_MD5;

Expand Down

0 comments on commit 6c3ea12

Please sign in to comment.