Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panicked with Parse(Unexpected("MailboxData(Recent(1))")) #81

Closed
kper opened this issue Jul 17, 2018 · 21 comments
Closed

Panicked with Parse(Unexpected("MailboxData(Recent(1))")) #81

kper opened this issue Jul 17, 2018 · 21 comments

Comments

@kper
Copy link

kper commented Jul 17, 2018

Hello!

I wrote a minimal example of my code, which works totally fine when only one guy sends an email. However, when I try to send an email from two different email addresses to server at the same time, my server panics.

Cargo.toml

[package]
name = "imap_test"
version = "0.1.0"
authors = ["Kevin Per <[email protected]>"]

[dependencies]
imap = "0.8.1"
native-tls = "0.1" 
mailparse = "0.6.2"

main.rs:

extern crate imap;
extern crate mailparse;
extern crate native_tls;

use imap::client::Client;
use native_tls::{TlsConnector, TlsStream};
use std::net::TcpStream;

use mailparse::*;

fn main() {
    let domain = "";
    let email = "";
    let password = "";


    let socket_addr = (domain.clone(), 993);
    let ssl_connector = TlsConnector::builder().unwrap().build().unwrap();
    let mut imap_socket =
        imap::client::Client::secure_connect(socket_addr, domain.clone(), &ssl_connector)
            .unwrap();

    imap_socket
        .login(email, password)
        .unwrap();

    loop {
        match imap_socket.select("INBOX") {
            Ok(mailbox) => {
                println!("{}", mailbox);
            }
            Err(e) => println!("Error selecting INBOX: {}", e),
        };

        let mut unseen = imap_socket
            .run_command_and_read_response("UID SEARCH UNSEEN 1:*")
            .unwrap();

        // remove last line of response (OK Completed)
        unseen.pop();

        let mut uids = Vec::new();
        let unseen = ::std::str::from_utf8(&unseen[..]).unwrap();
        let unseen = unseen.split_whitespace().skip(2);
        for uid in unseen.take_while(|&e| e != "" && e != "Completed") {
            if let Ok(uid) = usize::from_str_radix(uid, 10) {
                uids.push(format!("{}", uid));
            }
        }

        uids.reverse(); //latest first

        for uid in uids.iter() {
            let raw = imap_socket.uid_fetch(uid, "RFC822").unwrap(); //here it panics!

            for message in raw.iter() {
                let m = message.rfc822();

                if m.is_none() {
                    continue;
                }

                let parsed = parse_mail(m.unwrap()).unwrap();

                let subject = parsed.headers.get_first_value("Subject").unwrap().unwrap();
                let from = parsed.headers.get_first_value("From").unwrap().unwrap();

                if parsed.subparts.len() > 0 {
                    let body = parsed.subparts[0].get_body().unwrap();

                    println!("From: {}", from);
                    println!("Subject: {}", subject);
                    println!("Body: {}", body);
                }
            }
        }
    }
}
@kper
Copy link
Author

kper commented Jul 17, 2018

Error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Parse(Unexpected("MailboxData(Recent(1))"))', libcore/result.rs:945:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:475
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   6: rust_begin_unwind
             at libstd/panicking.rs:325
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   8: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:26
   9: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:782
  10: imap_test::main
             at src/main.rs:54
  11: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  12: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  13: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  14: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  15: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  16: main
  17: __libc_start_main
  18: _start

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 17, 2018

Hmm, I wonder if this is a bug in imap-proto. Perhaps @djc can shed some light on it?

@djc
Copy link

djc commented Jul 18, 2018

@jonhoo can you tell me what the Parse(Unexpected()) part is? Ideally I'd like to see the on-the-wire data, which would make it a bit easier to troubleshoot this.

@kper
Copy link
Author

kper commented Jul 18, 2018

Is there a good way to capture the on-the-wire-data?
I tried to capture it with Wireshark, unfortunately all imap servers I know are using ssl, therefore is everything encrypted and I have no idea how to extract the key.
https://serverfault.com/questions/360259/cant-decrypt-imaps-traffic-in-wireshark

@djc
Copy link

djc commented Jul 18, 2018

SSLKEYLOGFILE (https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format) can help depending on what TLS library you are using, and Wireshark can consume the resulting file. Otherwise you could insert some println!() calls in imap or imap-proto...

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 18, 2018

Actually, on a closer look, I think this errors stems from here, which suggests that the UID FETCH returns something this is not a Response::Fetch. Specifically, from the error you're giving, it gets a Response::MailboxData(Recent(1)) instead, which seems really odd?

A wire data trace would come in very handy here!

EDIT: keep in mind that you may want to remove the LOGIN part of the request to hide your password :)

@djc
Copy link

djc commented Jul 18, 2018

Reading the RFC, I think this might be an untagged (unsolicited) server message. That is, I think the assumption that you'll only get FETCH responses in response to a FETCH command is wrong.

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 18, 2018

What makes you say that? 6.4.5 says:

Responses:  untagged responses: FETCH

Which I take to mean that you should only get FETCH responses?

@kper
Copy link
Author

kper commented Jul 18, 2018

Thanks!

Here is the ssl stream from wireshark (I hope it is ok, that I posted it as comment, if you prefer I can export it)

Strangely, I get another error message today

* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
a1 LOGIN "[email protected]" "XXX"
a1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY NOTIFY METADATA QUOTA] Logged in
*a2 SELECT "INBOX"*
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 18 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 56] Predicted next UID
a2 OK [READ-WRITE] Select completed (0.007 + 0.000 + 0.006 secs).
a3 UID SEARCH UNSEEN 1:*
* SEARCH
a3 OK Search completed (0.001 + 0.000 secs).
a4 SELECT "INBOX"
* OK [CLOSED] Previous mailbox closed.
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 18 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 56] Predicted next UID
a4 OK [READ-WRITE] Select completed (0.002 + 0.000 + 0.001 secs).
a5 UID SEARCH UNSEEN 1:*
* SEARCH
a5 OK Search completed (0.001 + 0.000 secs).
a52 SELECT "INBOX"
* OK [CLOSED] Previous mailbox closed.
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 18 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 56] Predicted next UID
a52 OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
a53 UID SEARCH UNSEEN 1:*
* SEARCH
a53 OK Search completed (0.001 + 0.000 secs).
a54 SELECT "INBOX"
* OK [CLOSED] Previous mailbox closed.
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 18 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 56] Predicted next UID
a54 OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
a55 UID SEARCH UNSEEN 1:*
* SEARCH
* 19 EXISTS
a55 OK Search completed (0.008 + 0.000 + 0.007 secs).
a56 UID FETCH 19 RFC822
a56 OK Fetch completed (0.001 + 0.000 secs).
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Parse(Invalid([]))', libcore/result.rs:945:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:475
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   6: rust_begin_unwind
             at libstd/panicking.rs:325
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:77
   8: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:26
   9: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:782
  10: imap_test::main
             at src/main.rs:54
  11: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  12: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  13: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  14: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  15: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  16: main
  17: __libc_start_main
  18: _start

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 18, 2018

@kper you can probably remove some of the intermediate

a38 SELECT "INBOX"
* OK [CLOSED] Previous mailbox closed.
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 18 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 56] Predicted next UID
a38 OK [READ-WRITE] Select completed (0.001 + 0.000 + 0.001 secs).
a39 UID SEARCH UNSEEN 1:*
* SEARCH
a39 OK Search completed (0.001 + 0.000 secs).

segments to make it harder to read. This seems like a different issue though? Specifically, here you get Parse(Invalid([])), whereas previously you got a Parse(Unexpected(...))?

The Parse(Invalid([])) I comes from here when parsing this response:

a56 UID FETCH 19 RFC822
a56 OK Fetch completed (0.001 + 0.000 secs).

and I have a fix in mind for this that I'll push shortly.

jonhoo added a commit that referenced this issue Jul 18, 2018
@jonhoo
Copy link
Collaborator

jonhoo commented Jul 18, 2018

@kper can you try with dea9398 ? Won't fix the Unexpected, but should fix the Invalid, which might give us a trace for the Unexpected :)

@kper
Copy link
Author

kper commented Jul 19, 2018

Great! Thanks, the minimal example seems to run fine again :)

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 19, 2018

Hmm, that's so weird. This shouldn't fix the Unexpected you were seeing :/

@kper
Copy link
Author

kper commented Jul 19, 2018

I can't even explained why the error message changed - same emails, same server, same code

I'll run the patch on my test server for a few days. Let's see if I get any error message. If not I will close this issue after the weekend.

Huge thanks to you guys!

@kper
Copy link
Author

kper commented Jul 21, 2018

Ok, I managed to to reproduce the error from before. I replied on an email from the server several times, waited until the server printed it out and then replied again. This leads to the error:

thread 'main' panicked at 'called Result::unwrap() on an Err value: Parse(Unexpected("MailboxData(Recent(1))"))', libcore/result.rs:945:5

* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
a1 LOGIN "[email protected]" "XXX"
a1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY NOTIFY METADATA QUOTA] Logged in
a2 SELECT "INBOX"
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 72 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 110] Predicted next UID
a2 OK [READ-WRITE] Select completed (0.004 + 0.000 + 0.004 secs).
a3 UID SEARCH UNSEEN 1:*
* SEARCH
a3 OK Search completed (0.001 + 0.000 secs).
a134 SELECT "INBOX"
* OK [CLOSED] Previous mailbox closed.
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 73 EXISTS
* 1 RECENT
* OK [UNSEEN 73] First unseen.
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 111] Predicted next UID
a134 OK [READ-WRITE] Select completed (0.012 + 0.000 + 0.011 secs).
a135 UID SEARCH UNSEEN 1:*
* SEARCH 110
a135 OK Search completed (0.001 + 0.000 secs).
a136 UID FETCH 110 RFC822
* 73 FETCH (UID 110 FLAGS (\Seen \Recent) RFC822 {10272}
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from DIR-03 ([10.20.147.193])
	by IMAP-11 with LMTP id kFpYA2NRU1ujCwAAfkPEDA
	for <[email protected]>; Sat, 21 Jul 2018 11:29:39 -0400
Received: from MTA-03.privateemail.com ([10.20.147.13])
	by DIR-03 with LMTP id wAiOA2NRU1u2cAAAtNLlyA
	; Sat, 21 Jul 2018 11:29:39 -0400
Received: from oxse3.privateemail.com (unknown [10.20.151.236])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by MTA-03.privateemail.com (Postfix) with ESMTPS id 0A3D760050
	for <[email protected]>; Sat, 21 Jul 2018 15:29:39 +0000 (UTC)
Received: from mail-it0-f45.google.com ([209.85.214.45])
	by oxse3.privateemail.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
	(Exim 4.89)
	(envelope-from <[email protected]>)
	id 1fgtpB-0005JB-IP
	for [email protected]; Sat, 21 Jul 2018 08:29:38 -0700
Received: by mail-it0-f45.google.com with SMTP id h2-v6so18580426itj.1
        for <[email protected]>; Sat, 21 Jul 2018 08:29:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
        bh=u7Jb6kgK4/o25yJ8kpU688+5cQFTuoFP+lTyj/m7qto=;
        b=ln+/DYRitBFemZ12Ysd09THoD0hoGVKF+WkW+X+cYGLcb2T1ra82R98Fwt7Wmc+jwf
         ZKhEAxDmzTEPu1/nyFT5gxFP22N5slGIzy6NK1Mcaw31/o22Ai9ljbc2E4PeH0ZRX4LL
         1npesUgSDF9l2AUjGEs4bCAQRIbyXYqX0DtGyJsqHSeLHgavnEBhAI60EGcW04khWOyq
         FN4tKqUO33p1+3Jgatb8c1PDUDJ6XnZy4mwwnD7vHB3whNdlKwtNYinJsEL3Xm65RzsD
         JWXqnOUxkGkRBeFywqlDp4DBNm3b9JMyx2QSJkfO9lYMU4y4EM1edsNkGTSc53Ehyfey
         EXTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to;
        bh=u7Jb6kgK4/o25yJ8kpU688+5cQFTuoFP+lTyj/m7qto=;
        b=lZWKe9TL3nfiGP8hjEBCfzZ/lfsKONxd/t/aFmmUobyJGk+XY8n4769x41HjwkXfwl
         fTK2eu96A0iFtbFWOvdXltDHsYaQOGaXaMh042rkHZyOEVmHsz3yqC77gRI8Gm0GiNtA
         mzo15uS7vrjpjzawskmYnA9FVeLT3OVAXQ6RQ/odfX6bMajzeDMb/VG8lXTu177CZGu/
         5s0wEnvhE491GAdiH1H6OYx7Fi7UV1DsQsCPUR9lNiCrC/nvpYmrG2ohIaFCdNfcDHVg
         IE4ffiqFZzj0ZWERHyLrxvlf4YhIKL03WquQblbiBVkQ/e7mbGKMny9DGdLicTsd+NZV
         o5Dg==
X-Gm-Message-State: AOUpUlFjJio527bM9WivfDFiaTwrbImJX8pchekjwlq/Btzc9KFdUeCj
	a+A2UyoEifRRHcuhAd1eH16ta48IMsrdH7kpgzAipQ==
X-Google-Smtp-Source: AAOMgpemE1O4AstOQ6UuEpuPO2oevJ7IWijpl+TW3jxnQxiqGMLturilG8+T94GU9oo+qnlDWkh78/BrB7E3UpYKVJ8=
X-Received: by 2002:a24:a43:: with SMTP id 64-v6mr5382036itw.140.1532186976414;
 Sat, 21 Jul 2018 08:29:36 -0700 (PDT)
MIME-Version: 1.0
References: <79f41527-5313-4ac3-9269-dc1efa48ef7a.lettre@localhost>
 <CAP-G7fsEL2nVAGQYwNipbBuL9fg4vNv13GagMpnsPhmC5Z5EsA@mail.gmail.com>
 <CAP-G7fuRs4M3YjNPXp2vMto3LNu_o-ex5=xEXkeoWMezB_82kA@mail.gmail.com>
 <CAP-G7ftFjkNFYVa5rfvWdzzN9Ns7N_LpQWvtjht+bULwR8vwfQ@mail.gmail.com>
 <CAP-G7fvgFRrpir-4u19yjC5aw6BcxtwUfnsmHDJgiJ=xZ0AWvg@mail.gmail.com>
 <CAP-G7fuNVTb=fw9WYp+1-_H+-8eSwiQtsnk5XVPw827E6r1d3A@mail.gmail.com>
 <CAP-G7fvtDepziXHi3eX+868CO7mS1qRRmqcCD8v_25p-XtrmHw@mail.gmail.com>
 <CAP-G7ft-DJwxaGSZfZ3pi7dwgk_iZ=hpX7tDV7s8S5e3vjRK8g@mail.gmail.com> <CAP-G7ftELvbYt4wuST40V8o9KtX2DHf6yVa6hBxF5TR=Zpreeg@mail.gmail.com>
In-Reply-To: <CAP-G7ftELvbYt4wuST40V8o9KtX2DHf6yVa6hBxF5TR=Zpreeg@mail.gmail.com>
From: Kevin Per <[email protected]>
Date: Sat, 21 Jul 2018 17:29:24 +0200
Message-ID: <CAP-G7fvuKRgieRJWif=NNjPV0k5d15En1myGUJBh4vuvzkRE9g@mail.gmail.com>
Subject: Re: Game is over
To: [email protected]
Content-Type: multipart/alternative; boundary="0000000000007571d2057184147a"
Received-SPF: pass (oxse3.privateemail.com: domain of gmail.com designates 209.85.214.45 as permitted sender) client-ip=209.85.214.45; [email protected]; helo=mail-it0-f45.google.com;
X-SPF-Result: oxse3.privateemail.com: domain of gmail.com designates 209.85.214.45 as permitted sender
Authentication-Results: oxse3.privateemail.com; dmarc=pass header.from=gmail.com
Authentication-Results:  privateemail.com; spf=pass [email protected]; dkim=pass header.i=gmail.com
X-SpamExperts-Class: ham
X-SpamExperts-Evidence: Combined (0.12)
X-Recommended-Action: accept
X-Filter-ID: EX5BVjFpneJeBchSMxfU5hKaTdAHZq4lblFO3Id/+ZZ602E9L7XzfQH6nu9C/Fh9JZ2oUlufyjIr
 n38u2hmLrwUg23Soa/m0CT+apYXsazZqK64leeYaIjWPuCPLoijmzuskevG5DCTfDJc060MHnbrV
 wMEdQuFiHmZQIK5L2Dj6cq2Y9cANfWNkKBRmBM+b8nzl1ZmDZ6ve+7TWOZ9Q7t8d1wwc5rji3krU
 1KgK56pVr8eP+Wmp/y/AB2KysgGDLG+A9rRM6b1DNs0pCSMh6GSRVlmfqrN8WCxGnqeM8IPzuGTy
 VhqnEJapmWC60orzQa2g5BIIPoXIF6Y8MCL089mKwbedi9VmZIuJqzMlQ1jxDN9CbHrKYHXvYEGF
 c4c9QosLBoi+t7a/E/Seai/8ki9o7tbGRs2d5EgUPYgZTFhlT6wIKFmxzlUHOrWsSqAiVf1qzaRU
 c3P3olRHLamMQyb0mbZGjIHswS91OoTWbV36kfURYhvErzJeAK1geJC85xS/zVfrqzZpLvpYwP30
 rNhDlN3ZFexZfYgAG9qTPTrzvgwP9cMw+lye/qXkeuruqm5zmUSYVfKaixuILhBIYsqDvjC7i/GT
 H3zSocYXH532KiulfbWCI3iG/f9oGXVXljv0mY1fOG/etSq6TxYgdZ09j7OrMlY7yc+PPdQGYF0O
 aBe0Q65JvGVISs6+sBPfpNcfTUi2aLFw8qY+ak5ENM1etHmQ4XFW+rSsfEntrwCuwLVRaxGmTuoo
 HjPhae+Q6Ma09IKm0I18Njnl7e4BIjD326lPuiMNgAsQ8d8OiMZc9aUV1oY4fX3W5eOCNA39hsKQ
 GPvUZO/X+9bR7Q9jYAF+1jSRqT6ilb3y2DpNBxQ1sWG9NPPYQ9OQw31j6zwNYn91UUpcn6v9tXMv
 XO2dvSNuev6ZoZL1owl+cx82ZvWddawQ6tF6MHLiOPuAwXdWKpPsBuOiOQtWbeFbLXgHQfY4ocfm
 Wv3Fe9Iziczdq+A=
X-Report-Abuse-To: [email protected]

--0000000000007571d2057184147a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

test

Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um 17:25 Uhr:

> test 4
>
> Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um 17:25 Uhr=
:
>
>> test 3
>>
>> Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um
>> 17:25 Uhr:
>>
>>> test 2
>>>
>>> Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um
>>> 17:25 Uhr:
>>>
>>>> test
>>>>
>>>> Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um
>>>> 17:24 Uhr:
>>>>
>>>>> test 2
>>>>>
>>>>> Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um
>>>>> 17:24 Uhr:
>>>>>
>>>>>> test 1
>>>>>>
>>>>>> Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um
>>>>>> 17:24 Uhr:
>>>>>>
>>>>>>> test
>>>>>>>
>>>>>>> Kevin Per <[email protected]> schrieb am Sa., 21. Juli 2018 um
>>>>>>> 17:24 Uhr:
>>>>>>>
>>>>>>>> test
>>>>>>>>
>>>>>>>> <[email protected]> schrieb am Sa., 21. Juli 2018 um
>>>>>>>> 17:17 Uhr:
>>>>>>>>
>>>>>>>>> Das Spiel ist vorbei! Gewonnen hat Gr=C3=BCnen
>>>>>>>>>
>>>>>>>>

--0000000000007571d2057184147a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">test<br></div><br><div class=3D"gmail_quote"><div dir=3D"l=
tr">Kevin Per &lt;<a href=3D"mailto:[email protected]">[email protected]<=
/a>&gt; schrieb am Sa., 21. Juli 2018 um 17:25=C2=A0Uhr:<br></div><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex"><div dir=3D"ltr">test 4<br></div><br><div class=3D"gm=
ail_quote"><div dir=3D"ltr">Kevin Per &lt;<a href=3D"mailto:kevp.per@gmail.=
com" target=3D"_blank">[email protected]</a>&gt; schrieb am Sa., 21. Juli =
2018 um 17:25=C2=A0Uhr:<br></div><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr">test 3<br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">Kevin=
 Per &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">kevp.per@g=
mail.com</a>&gt; schrieb am Sa., 21. Juli 2018 um 17:25=C2=A0Uhr:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">test 2<br></div><br><div cl=
ass=3D"gmail_quote"><div dir=3D"ltr">Kevin Per &lt;<a href=3D"mailto:kevp.p=
[email protected]" target=3D"_blank">[email protected]</a>&gt; schrieb am Sa., =
21. Juli 2018 um 17:25=C2=A0Uhr:<br></div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"ltr">test<br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr=
">Kevin Per &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">kev=
[email protected]</a>&gt; schrieb am Sa., 21. Juli 2018 um 17:24=C2=A0Uhr:<br=
></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">test 2<br></div><br>=
<div class=3D"gmail_quote"><div dir=3D"ltr">Kevin Per &lt;<a href=3D"mailto=
:[email protected]" target=3D"_blank">[email protected]</a>&gt; schrieb a=
m Sa., 21. Juli 2018 um 17:24=C2=A0Uhr:<br></div><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr">test 1<br></div><br><div class=3D"gmail_quote"><div d=
ir=3D"ltr">Kevin Per &lt;<a href=3D"mailto:[email protected]" target=3D"_b=
lank">[email protected]</a>&gt; schrieb am Sa., 21. Juli 2018 um 17:24=C2=
=A0Uhr:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">test<br></=
div><br><div class=3D"gmail_quote"><div dir=3D"ltr">Kevin Per &lt;<a href=
=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>&gt;=
 schrieb am Sa., 21. Juli 2018 um 17:24=C2=A0Uhr:<br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div dir=3D"ltr">test<br></div><br><div class=3D"gmail_quote=
"><div dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a>&gt; schrieb am Sa., 21. Juli 2018 um 17:=
17=C2=A0Uhr:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Das Spiel ist vorbei! =
Gewonnen hat Gr=C3=BCnen<br>
</blockquote></div></blockquote></div>
</blockquote></div></blockquote></div>
</blockquote></div></blockquote></div></blockquote></div></blockquote></div=
>
</blockquote></div>

--0000000000007571d2057184147a--
)
a136 OK Fetch completed (0.020 + 0.000 + 0.019 secs).
a149 SELECT "INBOX"
* OK [CLOSED] Previous mailbox closed.
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 73 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1531815609] UIDs valid
* OK [UIDNEXT 111] Predicted next UID
a149 OK [READ-WRITE] Select completed (0.002 + 0.000 + 0.001 secs).
a150 UID SEARCH UNSEEN 1:*
* SEARCH
* 74 EXISTS
a150 OK Search completed (0.005 + 0.000 + 0.004 secs).
a151 UID FETCH 74 RFC822
* 37 FETCH (UID 74 RFC822 {5034}
Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from DIR-05 ([10.20.147.195])
	by IMAP-11 with LMTP id SKcHJ4SBUFueAwAAfkPEDA
	for <[email protected]>; Thu, 19 Jul 2018 08:18:12 -0400
Received: from MTA-04.privateemail.com ([10.20.147.14])
	by DIR-05 with LMTP id oPCsJoSBUFu8KAAA0YkaXQ
	; Thu, 19 Jul 2018 08:18:12 -0400
Received: from oxse2.privateemail.com (unknown [10.20.151.231])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by MTA-04.privateemail.com (Postfix) with ESMTPS id 95B35600C0
	for <[email protected]>; Thu, 19 Jul 2018 12:18:12 +0000 (UTC)
Received: from mail-io0-f172.google.com ([209.85.223.172])
	by oxse2.privateemail.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
	(Exim 4.89)
	(envelope-from <[email protected]>)
	id 1fg7sk-00026j-DR
	for [email protected]; Thu, 19 Jul 2018 05:18:12 -0700
Received: by mail-io0-f172.google.com with SMTP id l14-v6so6869733iob.7
        for <[email protected]>; Thu, 19 Jul 2018 05:18:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=mime-version:from:date:message-id:subject:to;
        bh=jVEJw5D9nsgUr9cWIMTZRIZPYvA1Hzo92qRkM34WjxA=;
        b=KhaD1M+ybtbhCVo5GJI+46cufxt6KKp4RC8O2EYFih4XfwS+izeOiBqZc2/htQNmGX
         KQX7cUxkPeCgBpnMjWHO/GFxcXc+6kk2vawSdLx7OLO9CKzBB2OErZBFqt9IiabDfAHV
         QG15W8lbeFsJrDqpkILBI7WFXS5tV3ftrvHrxzmhVGeKpNonJwqbXURcTbaSbbKkSfhv
         RcpJkut7OM5k7lKYPttDypTjWspSWUpGfSMhUtnyyHEr8s2q9BX3b7vBrRVs1FOr0819
         V8slGkF3EsbcLMCDsxPVp+g9p7E6tUSeFMxNcgsOYkK3uaQjYFKBYJCOj5RlMRHTNuA7
         YWoA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
        bh=jVEJw5D9nsgUr9cWIMTZRIZPYvA1Hzo92qRkM34WjxA=;
        b=dMEyHnPFkUJg1o2Zyo3ah17777HHkI3cqJ2+Bml167LKOPUSio2E0JhkTgeOzYdLxf
         yWZktOB3ptUYGI5Ux/uAYq4KXorh/Y+FqC8Il/6nFuWVjUq18PHg0rx8ggfiMKLUqgeN
         pyFoRWi42wQ96jui4cCieW3wX5zAP8z4uEV0Z9ufG6SBpsvFUh7OOwUxTNAFVJ7nPUgq
         zGzxHFICKouLakQGh8NxWhAgt5ZT46TlhYg4CzMufnjRtLMH/bFgu+++/jhqo0rL7oNi
         JG1M7/m8tCBWoXgDdcTwxgJVQ9HKtwenckrwu0JMD9B5RX7WYU8WOssRVKO1kcAEnt42
         g4VQ==
X-Gm-Message-State: AOUpUlH4yikYpxUQHjJylVp/rUemjazjxn+dtnAY4rI1Xg+ZWieCrl7y
	I7gD4wNdP8k4tBsqaqePj44L5G5pNINlBrhxKGeSBQ==
X-Google-Smtp-Source: AA+uWPw624HoZnNGd0onz/NEKmcZKfTdyVNSrNKXrRrXAJkyVMbA4PCNbA0tYggzckwIwn/nWr7nfCgF278wfPubL2E=
X-Received: by 2002:a6b:5d1a:: with SMTP id r26-v6mr8061340iob.170.1532002685223;
 Thu, 19 Jul 2018 05:18:05 -0700 (PDT)
MIME-Version: 1.0
From: Kevin Per <[email protected]>
Date: Thu, 19 Jul 2018 14:17:53 +0200
Message-ID: <CAP-G7fuF-JVc_5iFWY6xJV6Li1PsG_U0-EgSgJM__MXOuiZ5Gg@mail.gmail.com>
Subject: test
To: "[email protected]" <[email protected]>
Content-Type: multipart/alternative; boundary="000000000000d907fd0571592b5f"
Received-SPF: pass (oxse2.privateemail.com: domain of gmail.com designates 209.85.223.172 as permitted sender) client-ip=209.85.223.172; [email protected]; helo=mail-io0-f172.google.com;
X-SPF-Result: oxse2.privateemail.com: domain of gmail.com designates 209.85.223.172 as permitted sender
Authentication-Results: oxse2.privateemail.com; dmarc=pass header.from=gmail.com
Authentication-Results:  privateemail.com; spf=pass [email protected]; dkim=pass header.i=gmail.com
X-SpamExperts-Class: ham
X-SpamExperts-Evidence: Combined (0.14)
X-Recommended-Action: accept
X-Filter-ID: EX5BVjFpneJeBchSMxfU5puYTnQK8jyRtD0mP4Oa6ht602E9L7XzfQH6nu9C/Fh9JZ2oUlufyjIr
 n38u2hmLrwUg23Soa/m0CT+apYXsazZqK64leeYaIjWPuCPLoijmzuskevG5DCTfDJc060MHnbrV
 wMEdQuFiHmZQIK5L2Dj6cq2Y9cANfWNkKBRmBM+bdImxzz9WIsr5w7HYL/SUm98d1wwc5rji3krU
 1KgK56pVr8eP+Wmp/y/AB2KysgGDtQuRo9UgdFJAxIOiWyFxEmSRVlmfqrN8WCxGnqeM8IPzuGTy
 VhqnEJapmWC60orzQa2g5BIIPoXIF6Y8MCL089mKwbedi9VmZIuJqzMlQ1jxDN9CbHrKYHXvYEGF
 c4c9QosLBoi+t7a/E/Seai/8ki9o7tbGRs2d5EgUPYgZTFhlT6wIKFmxzlUHOrWsSqAiVf1qzaRU
 c3P3olRHLamMQyb0mbZGjIHswS91OoTWbV36kfURYhvErzJeAK1geJC85xS/zVfrqzZpLvpYwP30
 rNhDlN3ZFexZfYgAG9qTPTrzvgwP9cMw+lye/qXkeuruqm5zmUSYVfKaixuILhBIYsqDvjC7i/GT
 H3zSocYXH532KiulfbWCI3iG/f9oGXVXljv0mY1fOG/etSq6TxYgdaNSoflY5BjsW5v7Zf+amhOm
 zQYPXueDFSnZqsnjl8xdHLW65JhCds1d8gpTW3JOIhLISiBBtUKLS7to4sGmry7Y3BJihgpLqioq
 uprC5XGD6wLTmlotAKF9VriAm5rBfyiXNpC6v8Bm0MavXpPx8oAccBIk1Sag4dKiqCrF8eZZqgZn
 pdvY1LEHGpY+6P+P/6inZs1+OS2pexCLTOj8Wk+hKAD+didSf74QsEGiP/NnsgSF20u6FAYj3l+S
 x1RM+Wg8j7Lp4DUVI3KzrQ+aZAme0y26YP8oDmbcQEbTPOI3QVDgU8x/XonV574CjYPqsT0jDNqm
 ofR5hgtbEsa9ywg=
X-Report-Abuse-To: [email protected]

--000000000000d907fd0571592b5f
Content-Type: text/plain; charset="UTF-8"

Zug mit Turm nach Gmunden

--000000000000d907fd0571592b5f
Content-Type: text/html; charset="UTF-8"

<div dir="ltr">Zug mit Turm nach Gmunden<br></div>

--000000000000d907fd0571592b5f--
)
* 1 RECENT
a151 OK Fetch completed (0.010 + 0.000 + 0.009 secs).

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 21, 2018

Interesting... It looks like the response to your last FETCH:

a151 UID FETCH 74 RFC822

starts with

* 37 FETCH (UID 74 RFC822 {5034}
Return-Path: <[email protected]>
...
)

which is all good, but is then followed by:

* 1 RECENT

before it ends with

a151 OK Fetch completed (0.010 + 0.000 + 0.009 secs).

@djc from the RFC, I don't believe this is possible. AFAICT, only untagged FETCH responses should be sent in response to a FETCH command? Have you seen RECENT being returned as well?

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 21, 2018

Ahh, on further inspection of Section 7:

An example of unilateral untagged server data occurs when the IMAP
connection is in the selected state. In the selected state, the
server checks the mailbox for new messages as part of command
execution. Normally, this is part of the execution of every command;
hence, a NOOP command suffices to check for new messages. If new
messages are found, the server sends untagged EXISTS and RECENT
responses reflecting the new size of the mailbox.
Server
implementations that offer multiple simultaneous access to the same
mailbox SHOULD also send appropriate unilateral untagged FETCH and
EXPUNGE responses if another agent changes the state of any message
flags or expunges any messages.

@jonhoo jonhoo closed this as completed in 72925cf Jul 21, 2018
@jonhoo
Copy link
Collaborator

jonhoo commented Jul 21, 2018

@kper can you confirm that 72925cf indeed fixes the issue?

@kper
Copy link
Author

kper commented Jul 21, 2018

Looks good to me :)
Thanks

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 21, 2018

@mattnenterprise this also requires a release, or #69.

@djc
Copy link

djc commented Jul 21, 2018

@jonhoo nice find! I figured it was something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants