Discussion:
Using IMAP as POP, :mailbox taking a list?
Adam Sjøgren
2015-09-04 08:12:20 UTC
Permalink
Hi,


I'm using IMAP as POP at work (because the server is Microsoft Exchange,
i.e. reasons) in Gnus, and it works nicely.

To make email usable on the phone, however, I have configured Outlook to
sort incoming email into folders.

But I still want to fetch all [unseen] email into GNus, using IMAP as
POP.

So I have added 10 imap-entries to my mail-sources, each with a
different :mailbox value.

This works.

Except for one minor thing: it takes a while to establish the connection
to the mailserver 10 times (using ssl). Making getting my email fix a
little annoying.

So I was thinking: if the :mailbox value could be a list, then I could
have only one imap entry in mail-sources, and only one connection, and
Gnus could just fetch from each mailbox in the list.

Does that sound feasible? Reasonable? Any ideas at how to implement,
where to look?

(All this talk to avoid starting to look at the code myself, hmm...)


Best regards,

Adam
--
"Ge mig en vinterdrog Adam Sjøgren
Ge mig allt du har" ***@koldfront.dk
Eric S Fraga
2015-09-04 08:47:28 UTC
Permalink
On Friday, 4 Sep 2015 at 10:12, Adam Sjøgren wrote:

[...]
Post by Adam Sjøgren
Except for one minor thing: it takes a while to establish the connection
to the mailserver 10 times (using ssl). Making getting my email fix a
little annoying.
I am curious. I also have to put up with using an outlook server
(outlook.office365.com). In my case, I do use it as IMAP in its true
sense; I am not sure what you mean by using it as POP.

I also have the outlook server distribute some emails to different
folders, especially mailing lists. I used to use gnus's splitting
functionality, which I loved especially because the regexp patterns are
much more powerful and easy to use than Outlook's interface. I stopped
using splitting in gnus when I started using a phone to access my email
as well (as you) and only wanted some emails remaining in my INBOX for
the phone to access.

Does my use case also suffer from the same need to open the connection
more than once? I ask because fetching email from outlook is always
very slow. Would the same suggestion you are making improve full IMAP
use?

Thanks,
eric
--
: Eric S Fraga, GnuPG: 0xFFFCF67D
: in Emacs 25.0.50.2 + Ma Gnus v0.14 + evil-git-ff74cfb
: BBDB version 3.1.2 (2014-04-28 23:20:47+00:00)
Adam Sjøgren
2015-09-04 08:56:57 UTC
Permalink
Post by Eric S Fraga
I am curious. I also have to put up with using an outlook server
(outlook.office365.com). In my case, I do use it as IMAP in its true
sense; I am not sure what you mean by using it as POP.
I mean instead of manipulating the email on the server, Gnus fetches the
emails and stores them locally in an nnml: spool. Just as you would do
with POP.

See the imap section here: http://gnus.org/manual/gnus_84.html#Mail-Sources

[...]
Post by Eric S Fraga
Does my use case also suffer from the same need to open the connection
more than once?
No, because it sounds like you use IMAP as IMAP.

You probably have an nnimap entry in your select methods (either the
primary or one of the secondary). I don't. I have imap entries in my
mail-sources.
Post by Eric S Fraga
I ask because fetching email from outlook is always very slow. Would
the same suggestion you are making improve full IMAP use?
Not that I can see, no.


Best regards,

Adam
--
"Ge mig en vinterdrog Adam Sjøgren
Ge mig allt du har" ***@koldfront.dk
Eric S Fraga
2015-09-04 10:08:01 UTC
Permalink
On Friday, 4 Sep 2015 at 10:56, Adam Sjøgren wrote:

[...]
Post by Adam Sjøgren
Post by Eric S Fraga
I ask because fetching email from outlook is always very slow. Would
the same suggestion you are making improve full IMAP use?
Not that I can see, no.
thanks for the explanation. basically, I need to get away from
Outlook... ;-)
--
: Eric S Fraga, GnuPG: 0xFFFCF67D
: in Emacs 25.0.50.2 + Ma Gnus v0.14 + evil-git-ff74cfb
: BBDB version 3.1.2 (2014-04-28 23:20:47+00:00)
Adam Sjøgren
2015-09-04 09:25:08 UTC
Permalink
Post by Adam Sjøgren
So I was thinking: if the :mailbox value could be a list, then I could
have only one imap entry in mail-sources, and only one connection, and
Gnus could just fetch from each mailbox in the list.
It looks like in lisp/mail-source.el mail-source-fetch-imap is the
function I want to change to handle mailbox being a list.

But, uhm, my elisp-fu is too weak to understand where the variable
mailbox in that function comes from.

Hrmpf.

Ah, it looks like it is mail-source-bind that does the magic...


Best regards,

Adam
--
"I came from a household that showed as much Adam Sjøgren
knowledge or interest in sport as hedgehogs show in ***@koldfront.dk
embroidery."
Andreas Schwab
2015-09-04 09:52:23 UTC
Permalink
Post by Adam Sjøgren
So I was thinking: if the :mailbox value could be a list, then I could
have only one imap entry in mail-sources, and only one connection, and
Gnus could just fetch from each mailbox in the list.
Does that sound feasible? Reasonable? Any ideas at how to implement,
where to look?
Looks doable, see mail-source-fetch-imap. You probably just need to add
a loop over mailbox.

Andreas.
--
Andreas Schwab, ***@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Adam Sjøgren
2015-09-04 10:30:35 UTC
Permalink
Post by Andreas Schwab
Looks doable, see mail-source-fetch-imap. You probably just need to add
a loop over mailbox.
Yeah, I have got it working with this change:

--- a/lisp/mail-source.el
+++ b/lisp/mail-source.el
@@ -1090,10 +1090,13 @@ This only works when `display-time' is enabled."
(if (and (imap-open server port stream authentication buf)
(imap-authenticate
user (or (cdr (assoc from mail-source-password-cache))
- password) buf)
- (imap-mailbox-select mailbox nil buf))
+ password) buf))
+ (let ((mailbox-list (if (listp mailbox) mailbox (list mailbox))))
+ (dolist (mailbox mailbox-list)
+ (when (imap-mailbox-select mailbox nil buf)
(let ((coding-system-for-write mail-source-imap-file-coding-system)
str)
+ (message (format "Fetching from %s..." mailbox))
(with-temp-file mail-source-crash-box
;; Avoid converting 8-bit chars from inserted strings to
;; multibyte.
@@ -1128,8 +1131,7 @@ This only works when `display-time' is enabled."
fetchflag nil buf))
(if dontexpunge
(imap-mailbox-unselect buf)
- (imap-mailbox-close nil buf))
- (imap-close buf))
+ (imap-mailbox-close nil buf))))))
(imap-close buf)
;; We nix out the password in case the error
;; was because of a wrong password being given.


Now I just need to document and wrap it up nicely; I hope :-)

It is incredible how much writing about what you (I) can't figure out
motivates...


Best regards,

Adam
--
"Vi er fanget i en kø Adam Sjøgren
I lys og nærkontakt. ***@koldfront.dk
Hun sir at vi skal dø
Det gad jeg ikke have sagt"
Adam Sjøgren
2015-09-05 08:27:33 UTC
Permalink
Post by Adam Sjøgren
Now I just need to document and wrap it up nicely; I hope :-)
Fixed a problem with my first attempt, and tested both with list and
single (default) value; committed and pushed now:

* http://git.gnus.org/cgit/gnus.git/commit/?id=dac2389c304a108c6cb78c18e422f157aecbdb74


Best regards,

Adam
--
"I need someone to throw blue sky at me" Adam Sjøgren
***@koldfront.dk
Loading...