GNU bug report logs - #18130
rmail: allow for imaps proto

Previous Next

Package: emacs;

Reported by: Carlos Pita <carlosjosepita <at> gmail.com>

Date: Mon, 28 Jul 2014 17:01:01 UTC

Severity: normal

Tags: confirmed, patch

Merged with 18278, 26376

Found in version 25.2

Fixed in version 26.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18130 in the body.
You can then email your comments to 18130 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18130; Package emacs. (Mon, 28 Jul 2014 17:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Carlos Pita <carlosjosepita <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 28 Jul 2014 17:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: rmail: allow for imaps proto
Date: Mon, 28 Jul 2014 13:59:23 -0300
[Message part 1 (text/plain, inline)]
Currently mailutils movemail works with gmail imap using this:

movemail 'imaps://carlosjosepita%40gmail.com:XXXX <at> imap.gmail.com/INBOX'
RMAIL

but not this:

movemail --tls 'imap://carlosjosepita%40gmail.com:X
XXX <at> imap.gmail.com:993/INBOX' RMAIL

I wouldn't be difficult to support imaps in rmail, as it's just forwarding
the request to movemail, which already supports it. This way it would be
possible to use gmail imap in rmail.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18130; Package emacs. (Mon, 28 Jul 2014 17:11:02 GMT) Full text and rfc822 format available.

Message #8 received at 18130 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 18130 <at> debbugs.gnu.org
Subject: Re: bug#18130: Acknowledgement (rmail: allow for imaps proto)
Date: Mon, 28 Jul 2014 14:09:49 -0300
Same for pop / pops:

Error:

[loscar <at> localhost ~]$ movemail --tls
'pop://carlosjosepita%40gmail.com:crapulario <at> pop.gmail.com:995' test3
movemail: mailbox
`pop://carlosjosepita%40gmail.com:***@pop.gmail.com:995': cannot open:
Input/output error

Ok:

[loscar <at> localhost ~]$ movemail
'pops://carlosjosepita%40gmail.com:crapulario <at> pop.gmail.com:995' test3

Currently there's no way to use rmail with gmail via movemail.

On Mon, Jul 28, 2014 at 2:01 PM, GNU bug Tracking System
<help-debbugs <at> gnu.org> wrote:
> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
>  bug-gnu-emacs <at> gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 18130 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs <at> gnu.org unless you wish
> to report a problem with the Bug-tracking system.
>
> --
> 18130: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18130
> GNU Bug Tracking System
> Contact help-debbugs <at> gnu.org with problems




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18130; Package emacs. (Mon, 28 Jul 2014 19:08:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: rmail: allow for imaps proto
Date: Mon, 28 Jul 2014 16:07:12 -0300
The problem seems more general, indeed. Non recognized protocols are
taken to be filenames and expanded, as in:

maildir:/home/loscar/Mail/INBOX
->
/home/loscar/maildir:/home/loscar/Mail/INBOX

mailutils movemail is pretty smart, but rmail is dumbing it down. I
think a more transparent delegation to the mailutils workhorse is in
order.

On Mon, Jul 28, 2014 at 1:59 PM, Carlos Pita <carlosjosepita <at> gmail.com> wrote:
>
> Currently mailutils movemail works with gmail imap using this:
>
> movemail 'imaps://carlosjosepita%40gmail.com:XXXX <at> imap.gmail.com/INBOX'
> RMAIL
>
> but not this:
>
> movemail --tls
> 'imap://carlosjosepita%40gmail.com:XXXX <at> imap.gmail.com:993/INBOX' RMAIL
>
> I wouldn't be difficult to support imaps in rmail, as it's just forwarding
> the request to movemail, which already supports it. This way it would be
> possible to use gmail imap in rmail.
>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18130; Package emacs. (Mon, 28 Jul 2014 20:29:02 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: rmail: allow for imaps proto
Date: Mon, 28 Jul 2014 17:27:44 -0300
I've been doing some debugging. The problem is in
rmail-insert-inbox-text, which calls expand-file-name. I'm not sure
whether you intend to support anything more than mbox, pop and imap or
not, but then this documentation:

https://www.gnu.org/software/emacs/manual/html_node/emacs/Movemail.html#Movemail

is very misleading in at least two ways:

* It doesn't mention pops and imaps at all.

* It suggests that a larger number of protocols could be used with
mailutils movemail.

So there's a bug anyway:

* Either the documentation should clearly state that only "pop:...",
"imap:..." and "/path/...." specifications are supported, despite the
more powerful capabilities of mailutils movemail

* Or the other protocols supported by mailutils movemail should be
supported by rmail also. In this case, something has to be done before
the filename logic in rmail-insert-inbox-text, which will be broken in
many ways because of the protocol prefix.

On Mon, Jul 28, 2014 at 4:07 PM, Carlos Pita <carlosjosepita <at> gmail.com> wrote:
> The problem seems more general, indeed. Non recognized protocols are
> taken to be filenames and expanded, as in:
>
> maildir:/home/loscar/Mail/INBOX
> ->
> /home/loscar/maildir:/home/loscar/Mail/INBOX
>
> mailutils movemail is pretty smart, but rmail is dumbing it down. I
> think a more transparent delegation to the mailutils workhorse is in
> order.
>
> On Mon, Jul 28, 2014 at 1:59 PM, Carlos Pita <carlosjosepita <at> gmail.com> wrote:
>>
>> Currently mailutils movemail works with gmail imap using this:
>>
>> movemail 'imaps://carlosjosepita%40gmail.com:XXXX <at> imap.gmail.com/INBOX'
>> RMAIL
>>
>> but not this:
>>
>> movemail --tls
>> 'imap://carlosjosepita%40gmail.com:XXXX <at> imap.gmail.com:993/INBOX' RMAIL
>>
>> I wouldn't be difficult to support imaps in rmail, as it's just forwarding
>> the request to movemail, which already supports it. This way it would be
>> possible to use gmail imap in rmail.
>>




Merged 18130 18278. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 16 Aug 2014 17:47:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18130; Package emacs. (Mon, 08 Sep 2014 09:34:02 GMT) Full text and rfc822 format available.

Message #19 received at 18130 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 18130 <at> debbugs.gnu.org
Subject: Fwd: [PATCH] bug#18130: rmail.el: handle imaps, pops, and local
 source mailboxes (maildir, MH, etc.)
Date: Mon, 8 Sep 2014 06:33:18 -0300
[Message part 1 (text/plain, inline)]
Sergey has kindly contributed this patch I'm adding to the report because
I'm afraid it could get lost otherwise.
---------- Forwarded message ----------
From: "Sergey Poznyakoff" <gray <at> gnu.org>
Date: Aug 16, 2014 10:02 AM
Subject: [PATCH] bug#18130: rmail.el: handle imaps, pops, and local source
mailboxes (maildir, MH, etc.)
To: <bug-gnu-emacs <at> gnu.org>
Cc: "Carlos Pita" <carlosjosepita <at> gmail.com>, <bug-mailutils <at> gnu.org>

Hello,

When used with GNU Mailutils movemail, rmail handles only imap and pop
mailboxes[1].  However, the Mailutils movemail supports a much wider
set of mailbox formats (both remote and local).  This patch makes
rmail.el fully use the flexibility of GNU Mailutils.  In particular,
it makes it possible to use imaps and pops encrypted protocols.  The
patch is against the current Emacs trunk.  The bug has been reported by
Carlos Pita to both GNU Emacs[2] and Mailutuls[3].

[1] http://lists.gnu.org/archive/html/bug-mailutils/2014-07/msg00008.html.
[2] http://lists.gnu.org/archive/html/bug-gnu-emacs/2014-07/msg00867.html
    http://lists.gnu.org/archive/html/bug-gnu-emacs/2014-07/msg00869.html
[3] http://lists.gnu.org/archive/html/bug-mailutils/2014-08/msg00000.html.

* lisp/mail/rmail.el (rmail-remote-proto-p): New function.
(rmail-parse-url): Return actual proto in the 2nd list element
instead of the mere t. All callers updated. Do not require
password unless the argument refers to a remote mailbox.
(rmail-insert-inbox-text): Select a proper message depending
on whether source mailbox is a remote one or not.
Hanlde non-plainfile local source mailboxes (maildir, MH, etc.)
---
 lisp/mail/rmail.el | 58
+++++++++++++++++++++++++++++++-----------------------
 1 file changed, 33 insertions(+), 25 deletions(-)

diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index f769204..a3d6343 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1869,13 +1869,16 @@ not be a new one).  It returns non-nil if it got
any new messages."
        (setq result (> new-messages 0))
        result))))

+(defun rmail-remote-proto-p (proto)
+  (string-match "^\\(\\(imap\\|pop\\)s?\\)$" proto))
+
 (defun rmail-parse-url (file)
-  "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD
GOT-PASSWORD)
+  "Parse the supplied URL. Return (list MAILBOX-NAME PROTO PASSWORD
GOT-PASSWORD)
 WHERE MAILBOX-NAME is the name of the mailbox suitable as argument to the
-actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to
-a remote mailbox, PASSWORD is the password if it should be
-supplied as a separate argument to `movemail' or nil otherwise,
GOT-PASSWORD
-is non-nil if the user has supplied the password interactively.
+actual version of `movemail', PROTO is the protocol (use
rmail-remote-proto-p
+to see if it refers to a remote mailbox), PASSWORD is the password if it
+should be supplied as a separate argument to `movemail' or nil otherwise,
+GOT-PASSWORD is non-nil if the user has supplied the password
interactively.
 "
   (cond
    ((string-match
"^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file)
@@ -1886,24 +1889,26 @@ is non-nil if the user has supplied the password
interactively.
            (host  (substring file (or (match-end 2)
                                       (+ 3 (match-end 1))))))

-       (if (not pass)
-           (when rmail-remote-password-required
-             (setq got-password (not (rmail-have-password)))
-             (setq supplied-password (rmail-get-remote-password
-                                      (string-equal proto "imap"))))
-         ;; The password is embedded.  Strip it out since movemail
-         ;; does not really like it, in spite of the movemail spec.
-         (setq file (concat proto "://" user "@" host)))
+       (if (rmail-remote-proto-p proto)
+           (if (not pass)
+               (when rmail-remote-password-required
+                 (setq got-password (not (rmail-have-password)))
+                 (setq supplied-password (rmail-get-remote-password
+                                          (string-match "imaps?" proto))))
+             ;; FIXME
+             ;; The password is embedded.  Strip it out since movemail
+             ;; does not really like it, in spite of the movemail spec.
+             (setq file (concat proto "://" user "@" host))))

        (if (rmail-movemail-variant-p 'emacs)
            (if (string-equal proto "pop")
                (list (concat "po:" user ":" host)
-                     t
+                     proto
                      (or pass supplied-password)
                      got-password)
              (error "Emacs movemail does not support %s protocol" proto))
          (list file
-               (or (string-equal proto "pop") (string-equal proto "imap"))
+               proto
                (or supplied-password pass)
                got-password))))

@@ -1971,18 +1976,18 @@ Value is the size of the newly read mail after
conversion."
   (or (memq (file-locked-p buffer-file-name) '(nil t))
       (error "RMAIL file %s is locked"
             (file-name-nondirectory buffer-file-name)))
-  (let (file tofile delete-files movemail popmail got-password password)
+  (let (file tofile delete-files movemail proto got-password password)
     (while files
       ;; Handle remote mailbox names specially; don't expand as filenames
       ;; in case the userid contains a directory separator.
       (setq file (car files))
       (let ((url-data (rmail-parse-url file)))
        (setq file (nth 0 url-data))
-       (setq popmail (nth 1 url-data))
+       (setq proto (nth 1 url-data))
        (setq password (nth 2 url-data))
        (setq got-password (nth 3 url-data)))

-      (if popmail
+      (if proto
          (setq renamep t)
        (setq file (file-truename
                    (substitute-in-file-name (expand-file-name file)))))
@@ -2003,14 +2008,16 @@ Value is the size of the newly read mail after
conversion."
                     (expand-file-name buffer-file-name))))
       ;; Always use movemail to rename the file,
       ;; since there can be mailboxes in various directories.
-      (when (not popmail)
+      (when (not proto)
        ;; On some systems, /usr/spool/mail/foo is a directory
        ;; and the actual inbox is /usr/spool/mail/foo/foo.
        (if (file-directory-p file)
            (setq file (expand-file-name (user-login-name)
                                         file))))
-      (cond (popmail
-            (message "Getting mail from the remote server ..."))
+      (cond (proto
+            (message (if (rmail-remote-proto-p proto)
+                         "Getting mail from the remote server ..."
+                       (concat "Getting mail from " proto))))
            ((and (file-exists-p tofile)
                  (/= 0 (nth 7 (file-attributes tofile))))
             (message "Getting mail from %s..." tofile))
@@ -2021,7 +2028,7 @@ Value is the size of the newly read mail after
conversion."
       ;; rename or copy the file FILE to TOFILE if and as appropriate.
       (cond ((not renamep)
             (setq tofile file))
-           ((or (file-exists-p tofile) (and (not popmail)
+           ((or (file-exists-p tofile) (and (not proto)
                                             (not (file-exists-p file))))
             nil)
            (t
@@ -2056,9 +2063,10 @@ Value is the size of the newly read mail after
conversion."
                   ;; If we just read the password, most likely it is
                   ;; wrong.  Otherwise, see if there is a specific
                   ;; reason to think that the problem is a wrong passwd.
-                  (if (or got-password
-                          (re-search-forward rmail-remote-password-error
-                                             nil t))
+                  (if (and (rmail-remote-proto-p proto)
+                           (or got-password
+                               (re-search-forward
rmail-remote-password-error
+                                                  nil t)))
                       (rmail-set-remote-password nil))

                   ;; If using Mailutils, remove initial error code
--
1.7.12.1
[Message part 2 (text/html, inline)]

Merged 18130 18278 26376. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 09 Apr 2017 01:08:02 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 09 Apr 2017 01:08:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 18278 <at> debbugs.gnu.org and Sergey Poznyakoff <gray <at> gnu.org> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 09 Apr 2017 01:45:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 07 May 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 45 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.