1 ;;; webmail.el --- interfacing with web mail
2 ;; Copyright (C) 1999 Free Software Foundation, Inc.
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
5 ;; Keywords: hotmail yahoo netaddress my-deja
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 2, or (at your
12 ;; option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
26 ;; Note: You need to have `url' and `w3' installed for this backend to
27 ;; work. `w3' must be 4.0pre46+one-line-cookie patch or standalone
30 ;; Todo: To support more web mail servers.
33 ;; 1. Net@ddress may corrupt `X-Face'.
36 ;; Webmail is an experimental function, which means NO WARRANTY.
40 (eval-when-compile (require 'cl))
56 ;; Report failure to find w3 at load time if appropriate.
66 (defvar webmail-type-definition
68 ;; Hotmail hate other HTTP user agents and use one line cookie
69 (paranoid agent cookie post)
70 (address . "www.hotmail.com")
71 (open-url "http://www.hotmail.com/")
72 (open-snarf . webmail-hotmail-open)
73 ;; W3 hate redirect POST
75 "http://%s/cgi-bin/dologin?login=%s&passwd=%s&enter=Sign+in&sec=no&curmbox=ACTIVE&_lang=&js=yes&id=2&tw=-10000&beta="
76 webmail-aux user password)
77 (list-snarf . webmail-hotmail-list)
78 (article-snarf . webmail-hotmail-article)
80 "%s&login=%s&f=33792&curmbox=ACTIVE&_lang=&js=&foo=inbox&page=&%s=on&Move+To.x=Move+To&tobox=trAsH"
83 (paranoid cookie post)
84 (address . "mail.yahoo.com")
85 (open-url "http://mail.yahoo.com/")
86 (open-snarf . webmail-yahoo-open)
87 (login-url;; yahoo will not accept GET
90 ".tries=1&.src=ym&.last=&promo=&lg=us&.intl=us&.bypass=&.chkP=Y&.done=http%%253a%%2F%%2Fedit.yahoo.com%%2Fconfig%%2Fmail%%253f.intl%%3D&login=%s&passwd=%s"
92 (login-snarf . webmail-yahoo-login)
93 (list-url "%s&rb=Inbox&YN=1" webmail-aux)
94 (list-snarf . webmail-yahoo-list)
95 (article-snarf . webmail-yahoo-article)
97 "%s/ym/us/ShowFolder?YY=52107&inc=50&order=down&sort=date&pos=0&box=Inbox&DEL=Delete&destBox=&Mid=%s&destBox2="
100 (paranoid cookie post)
101 (address . "www.netaddress.com")
102 (open-url "http://www.netaddress.com/")
103 (open-snarf . webmail-netaddress-open)
107 "LoginState=2&SuccessfulLogin=%%2Ftpl&NewServerName=www.netaddress.com&JavaScript=JavaScript1.2&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=%s&passwd=%s"
109 (login-snarf . webmail-netaddress-login)
111 "http://www.netaddress.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True"
113 (list-snarf . webmail-netaddress-list)
114 (article-snarf . webmail-netaddress-article)
116 "http://www.netaddress.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1"
119 (paranoid cookie post)
120 (address . "www.my-deja.com")
121 (open-url "http://www.my-deja.com/")
122 (open-snarf . webmail-my-deja-open)
126 "user=%s&pw=%s&autologout=60&go="
128 (list-url "http://www.deja.com/rg_gotomail.xp")
129 (list-snarf . webmail-my-deja-list)
130 (article-snarf . webmail-my-deja-article)
132 "%s/gmm_multiplex.femail?%%2Fgmm_domovemesg_top.femail=Move+to%%3A&folder_top=%s%%3Azzz%%3A%%7E6trash%%3AF%%3A0&docid=%s"
133 webmail-aux user id))))
135 (defvar webmail-variables
136 '(address article-snarf article-url list-snarf list-url
137 login-url login-snarf open-url open-snarf site articles
138 post-process paranoid trash-url))
140 (defconst webmail-version "webmail 1.0")
142 (defvar webmail-newmail-only nil
143 "Only fetch new mails.")
145 (defvar webmail-move-to-trash-can t
146 "Move mail to trash can after fetch it.")
148 ;;; Internal variables
150 (defvar webmail-address nil)
151 (defvar webmail-paranoid nil)
152 (defvar webmail-aux nil)
153 (defvar webmail-session nil)
154 (defvar webmail-article-snarf nil)
155 (defvar webmail-article-url nil)
156 (defvar webmail-list-snarf nil)
157 (defvar webmail-list-url nil)
158 (defvar webmail-login-url nil)
159 (defvar webmail-login-snarf nil)
160 (defvar webmail-open-snarf nil)
161 (defvar webmail-open-url nil)
162 (defvar webmail-trash-url nil)
163 (defvar webmail-articles nil)
164 (defvar webmail-post-process nil)
166 (defvar webmail-buffer nil)
167 (defvar webmail-buffer-list nil)
169 (defvar webmail-type nil)
171 ;;; Interface functions
173 (defun webmail-error (str)
174 (error "%s HTML has changed; please get a new version of webmail (%s)"
177 (defun webmail-setdefault (type)
178 (let ((type-def (cdr (assq type webmail-type-definition)))
179 (vars webmail-variables)
181 (setq webmail-type type)
183 (if (setq pair (assq var type-def))
184 (set (intern (concat "webmail-" (symbol-name var))) (cdr pair))
185 (set (intern (concat "webmail-" (symbol-name var))) nil)))))
187 (defun webmail-encode-www-form-urlencoded (pairs)
188 "Return PAIRS encoded for forms."
192 (concat (w3-form-encode-xwfu (car data)) "="
193 (w3-form-encode-xwfu (cdr data)))))
196 (defun webmail-fetch-simple (url content)
197 (let ((url-request-data content)
198 (url-request-method "POST")
199 (url-request-extra-headers
200 '(("Content-type" . "application/x-www-form-urlencoded"))))
204 (defun webmail-fetch-form (url pairs)
205 (let ((url-request-data (webmail-encode-www-form-urlencoded pairs))
206 (url-request-method "POST")
207 (url-request-extra-headers
208 '(("Content-type" . "application/x-www-form-urlencoded"))))
212 (defun webmail-eval (expr)
215 (cons (webmail-eval (car expr)) (webmail-eval (cdr expr))))
221 (defun webmail-url (xurl)
222 (mm-with-unibyte-current-buffer
224 ((eq (car xurl) 'content)
226 (webmail-fetch-simple (if (stringp (car xurl))
228 (apply 'format (webmail-eval (car xurl))))
229 (apply 'format (webmail-eval (cdr xurl)))))
230 ((eq (car xurl) 'post)
232 (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
234 (nnweb-insert (apply 'format (webmail-eval xurl)))))))
236 (defun webmail-init ()
237 "Initialize buffers and such."
238 (if (gnus-buffer-live-p webmail-buffer)
239 (set-buffer webmail-buffer)
241 (nnheader-set-temp-buffer " *webmail*"))))
243 (defvar url-package-name)
244 (defvar url-package-version)
245 (defvar url-cookie-multiple-line)
246 (defvar url-confirmation-func)
248 ;; Hack W3 POST redirect. See `url-parse-mime-headers'.
250 ;; Netscape uses "GET" as redirect method when orignal method is POST
251 ;; and status is 302, .i.e no security risks by default without
254 ;; Some web servers (at least Apache used by yahoo) return status 302
255 ;; instead of 303, though they mean 303.
257 (defun webmail-url-confirmation-func (prompt)
259 ((equal prompt (concat "Honor redirection with non-GET method "
260 "(possible security risks)? "))
262 ((equal prompt "Continue (with method of GET)? ")
266 (defun webmail-refresh-redirect ()
267 "Redirect refresh url in META."
268 (goto-char (point-min))
269 (while (re-search-forward
270 "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
272 (let ((url (match-string 1)))
274 (mm-with-unibyte-current-buffer
276 (goto-char (point-min))))
278 (defun webmail-fetch (file subtype user password)
280 (webmail-setdefault subtype)
281 (let ((url-package-name (if (memq 'agent webmail-paranoid)
284 (url-package-version (if (memq 'agent webmail-paranoid)
286 url-package-version))
287 (url-cookie-multiple-line (if (memq 'cookie webmail-paranoid)
289 url-cookie-multiple-line))
290 (url-confirmation-func (if (memq 'post webmail-paranoid)
291 'webmail-url-confirmation-func
292 url-confirmation-func))
293 url-cookie-storage url-cookie-secure-storage
294 url-cookie-confirmation
297 (setq webmail-articles nil)
298 (when webmail-open-url
300 (webmail-url webmail-open-url))
301 (if webmail-open-snarf (funcall webmail-open-snarf))
302 (when webmail-login-url
304 (webmail-url webmail-login-url))
305 (if webmail-login-snarf
306 (funcall webmail-login-snarf))
307 (when webmail-list-url
309 (webmail-url webmail-list-url))
310 (if webmail-list-snarf
311 (funcall webmail-list-snarf))
312 (while (setq item (pop webmail-articles))
313 (message "Fetching mail #%d..." (setq n (1+ n)))
315 (mm-with-unibyte-current-buffer
316 (nnweb-insert (cdr item)))
318 (if webmail-article-snarf
319 (funcall webmail-article-snarf file id))
320 (when (and webmail-trash-url webmail-move-to-trash-can)
321 (message "Move mail #%d to trash can..." n)
324 (webmail-url webmail-trash-url)
326 (while (setq buf (pop webmail-buffer-list))
330 (while (setq buf (pop webmail-buffer-list))
333 (if webmail-post-process
334 (funcall webmail-post-process))))
338 (defun webmail-hotmail-open ()
339 (goto-char (point-min))
340 (if (re-search-forward
341 "action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t)
342 (setq webmail-aux (match-string 1))
343 (webmail-error "open@1")))
345 (defun webmail-hotmail-list ()
347 (goto-char (point-min))
348 (if (re-search-forward "[0-9]+ messages, [0-9]+ new" nil t)
349 (message "Found %s" (match-string 0))
350 (webmail-error "maybe your w3 version is too old"))
351 (goto-char (point-min))
352 (if (re-search-forward
353 "action=\"https?://\\([^/]+\\)/cgi-bin/HoTMaiL" nil t)
354 (setq site (match-string 1))
355 (webmail-error "list@1"))
356 (goto-char (point-min))
357 (if (re-search-forward "disk=\\([^&]+\\)&" nil t)
359 (concat "http://" site "/cgi-bin/HoTMaiL?disk="
361 (webmail-error "list@2"))
362 (goto-char (point-max))
363 (while (re-search-backward
364 "newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\""
366 (if (setq url (match-string 1))
368 (if (or newp (not webmail-newmail-only))
370 (if (string-match "msg=\\([^&]+\\)" url)
371 (setq id (match-string 1 url)))
372 (push (cons id (concat "http://" site url))
377 (defun webmail-hotmail-article (file id)
378 (let (p attachment count mime)
380 (goto-char (point-min))
381 (if (not (search-forward "<DIV>" nil t))
382 (webmail-error "article@1"))
383 (narrow-to-region (point-min) (match-beginning 0))
384 (if (not (search-backward "<table" nil t 2))
385 (webmail-error "article@1.1"))
386 (delete-region (point-min) (match-beginning 0))
387 (while (search-forward "<a href=" nil t)
388 (setq p (match-beginning 0))
389 (search-forward "</a>" nil t)
390 (delete-region p (match-end 0)))
391 (nnweb-remove-markup)
392 (nnweb-decode-entities)
393 (goto-char (point-min))
395 (goto-char (point-min))
396 (when (search-forward "\n\n" nil t)
398 (delete-region (point) (point-max)))
399 (goto-char (point-max))
403 (while (re-search-forward
404 "<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\""
406 (if (setq attachment (match-string 1))
407 (let ((filename (match-string 2))
408 bufname);; Attachment
409 (delete-region p (match-end 0))
411 (set-buffer (generate-new-buffer " *webmail-att*"))
412 (nnweb-insert attachment)
413 (push (current-buffer) webmail-buffer-list)
414 (setq bufname (buffer-name)))
416 (insert "<#part type="
418 (string-match "\\.[^\\.]+$" filename)
419 (mailcap-extension-to-mime
420 (match-string 0 filename)))
421 "application/octet-stream"))
422 (insert " buffer=\"" bufname "\"")
423 (insert " filename=\"" filename "\"")
424 (insert " disposition=\"inline\"")
425 (insert "><#/part>\n")
427 (delete-region p (match-end 0))
429 (while (and (> count 0)
430 (re-search-forward "</div>\\|\\(<div>\\)" nil t))
432 (setq count (1+ count))
433 (if (= (setq count (1- count)) 0)
434 (delete-region (match-beginning 0)
436 (narrow-to-region p (point))
437 (goto-char (point-min))
439 ((looking-at "<pre>")
440 (goto-char (match-end 0))
441 (if (looking-at "$") (forward-char))
442 (delete-region (point-min) (point))
443 (nnweb-remove-markup)
444 (nnweb-decode-entities)
448 (insert "<#part type=\"text/html\" disposition=inline>")
449 (goto-char (point-max))
450 (insert "<#/part>")))
451 (goto-char (point-max))
454 (delete-region p (point-max))
455 (goto-char (point-min))
456 ;; Some blank line to seperate mails.
457 (insert "\n\nFrom nobody " (current-time-string) "\n")
459 (insert "Message-ID: <" id "@hotmail.com>\n"))
460 (unless (looking-at "$")
461 (if (search-forward "\n\n" nil t)
463 (webmail-error "article@2")))
464 (narrow-to-region (point) (point-max))
466 (insert "MIME-Version: 1.0\n"
469 (delete-region (point-min) (point-max)))))
470 (goto-char (point-min))
472 (let (case-fold-search)
473 (while (re-search-forward "^From " nil t)
476 (mm-append-to-file (point-min) (point-max) file)))
480 (defun webmail-yahoo-open ()
481 (goto-char (point-min))
482 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
483 (setq webmail-aux (match-string 1))
484 (webmail-error "open@1")))
486 (defun webmail-yahoo-login ()
487 (goto-char (point-min))
488 (if (re-search-forward "http://[a-zA-Z][0-9]\\.mail\\.yahoo\\.com/" nil t)
489 (setq webmail-aux (match-string 0))
490 (webmail-error "login@1"))
491 (if (re-search-forward "YY=[0-9]+" nil t)
492 (setq webmail-aux (concat webmail-aux "ym/us/ShowFolder?"
494 (webmail-error "login@2")))
496 (defun webmail-yahoo-list ()
497 (let (url (newp t) (tofetch 0))
498 (goto-char (point-min))
499 (when (re-search-forward
500 "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
501 ;;(setq listed (match-string 1))
502 (message "Found %s mail(s)" (match-string 2)))
503 (if (string-match "http://[^/]+" webmail-aux)
504 (setq webmail-aux (match-string 0 webmail-aux))
505 (webmail-error "list@1"))
506 (goto-char (point-min))
507 (while (re-search-forward
508 "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/us/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
510 (if (setq url (match-string 1))
512 (when (or newp (not webmail-newmail-only))
513 (push (cons (match-string 2) (concat webmail-aux url "&toc=1"))
515 (setq tofetch (1+ tofetch)))
518 (message "Fetching %d mail(s)" tofetch)))
520 (defun webmail-yahoo-article (file id)
523 (goto-char (point-min))
524 (if (not (search-forward "value=\"Done\"" nil t))
525 (webmail-error "article@1"))
526 (if (not (search-forward "<table" nil t))
527 (webmail-error "article@2"))
528 (delete-region (point-min) (match-beginning 0))
529 (if (not (search-forward "</table>" nil t))
530 (webmail-error "article@3"))
531 (narrow-to-region (point-min) (match-end 0))
532 (while (search-forward "<a href=" nil t)
533 (setq p (match-beginning 0))
534 (search-forward "</a>" nil t)
535 (delete-region p (match-end 0)))
536 (nnweb-remove-markup)
537 (nnweb-decode-entities)
538 (goto-char (point-min))
540 (goto-char (point-max))
544 (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
545 (setq attachment (match-string 0))
546 (let (bufname ct ctl cd description)
547 (if (not (search-forward "<table" nil t))
548 (webmail-error "article@4"))
549 (delete-region p (match-beginning 0))
550 (if (not (search-forward "</table>" nil t))
551 (webmail-error "article@5"))
552 (narrow-to-region p (match-end 0))
553 (nnweb-remove-markup)
554 (nnweb-decode-entities)
555 (goto-char (point-min))
557 (setq ct (mail-fetch-field "content-type")
558 ctl (ignore-errors (mail-header-parse-content-type ct))
559 ;;cte (mail-fetch-field "content-transfer-encoding")
560 cd (mail-fetch-field "content-disposition")
561 description (mail-fetch-field "content-description")
562 id (mail-fetch-field "content-id"))
563 (delete-region (point-min) (point-max))
566 (set-buffer (generate-new-buffer " *webmail-att*"))
567 (nnweb-insert (concat webmail-aux attachment))
568 (push (current-buffer) webmail-buffer-list)
569 (setq bufname (buffer-name)))
571 (if (and ctl (not (equal (car ctl) "text/")))
572 (insert " type=\"" (car ctl) "\""))
573 (insert " buffer=\"" bufname "\"")
575 (insert " disposition=\"" cd "\""))
577 (insert " description=\"" description "\""))
578 (insert "><#/part>\n")
580 (delete-region p (point-max))
581 (goto-char (point-min))
582 ;; Some blank line to seperate mails.
583 (insert "\n\nFrom nobody " (current-time-string) "\n")
585 (insert "Message-ID: <" id "@yahoo.com>\n"))
586 (unless (looking-at "$")
587 (if (search-forward "\n\n" nil t)
589 (webmail-error "article@2")))
590 (narrow-to-region (point) (point-max))
591 (insert "MIME-Version: 1.0\n"
594 (delete-region (point-min) (point-max))))
595 (goto-char (point-min))
597 (let (case-fold-search)
598 (while (re-search-forward "^From " nil t)
601 (mm-append-to-file (point-min) (point-max) file)))
605 (defun webmail-netaddress-open ()
606 (goto-char (point-min))
607 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
608 (setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
609 (webmail-error "open@1")))
611 (defun webmail-netaddress-login ()
612 (webmail-refresh-redirect)
613 (goto-char (point-min))
614 (if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t)
615 (setq webmail-session (match-string 1))
616 (webmail-error "login@1")))
618 (defun webmail-netaddress-list ()
620 (goto-char (point-min))
621 (when (re-search-forward
622 "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t)
623 (message "Found %s mail(s), %s unread"
624 (match-string 2) (match-string 1)))
625 (goto-char (point-min))
626 (while (re-search-forward
627 "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
628 (if (setq id (match-string 2))
631 (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
632 (car webmail-open-url)
633 webmail-session id)))
634 (if (or (not webmail-newmail-only)
635 (equal (match-string 1) "True"))
636 (push item webmail-articles))))))
638 (defun webmail-netaddress-single-part ()
639 (goto-char (point-min))
641 ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
644 (while (re-search-forward "[\t\040\r\n]+" nil t)
646 (goto-char (point-min))
647 (while (re-search-forward "<br>" nil t)
648 (replace-match "\n"))
649 (nnweb-remove-markup)
650 (nnweb-decode-entities)
653 (insert "<#part type=\"text/html\" disposition=inline>")
654 (goto-char (point-max))
658 (defun webmail-netaddress-article (file id)
659 (let (p p1 attachment count mime type)
661 (goto-char (point-min))
662 (if (not (search-forward "Trash" nil t))
663 (webmail-error "article@1"))
664 (if (not (search-forward "<form>" nil t))
665 (webmail-error "article@2"))
666 (delete-region (point-min) (match-beginning 0))
667 (if (not (search-forward "</form>" nil t))
668 (webmail-error "article@3"))
669 (narrow-to-region (point-min) (match-end 0))
670 (goto-char (point-min))
671 (while (re-search-forward "[\040\t\r\n]+" nil t)
673 (goto-char (point-min))
674 (while (search-forward "<b>" nil t)
675 (replace-match "\n"))
676 (nnweb-remove-markup)
677 (nnweb-decode-entities)
678 (goto-char (point-min))
680 (goto-char (point-min))
681 (while (re-search-forward "^\040+\\|\040+$" nil t)
683 (goto-char (point-min))
684 (while (re-search-forward "\040+" nil t)
686 (goto-char (point-max))
690 (unless (search-forward "<!-- Data -->" nil t)
691 (webmail-error "article@4"))
693 (delete-region p (point))
694 (goto-char (point-max))
695 (unless (re-search-backward
696 "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
697 (webmail-error "article@5"))
698 (delete-region (point) (point-max))
700 (while (search-forward
701 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
704 (unless (search-forward "</TABLE>" nil t)
705 (webmail-error "article@6"))
707 (if (search-backward "<IMG " p t)
709 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
710 (webmail-error "article@7"))
711 (setq attachment (match-string 1))
712 (setq type (match-string 2))
713 (unless (search-forward "</TABLE>" nil t)
714 (webmail-error "article@8"))
715 (delete-region p (point))
716 (let (bufname);; Attachment
718 (set-buffer (generate-new-buffer " *webmail-att*"))
719 (nnweb-insert (concat (car webmail-open-url) attachment))
720 (push (current-buffer) webmail-buffer-list)
721 (setq bufname (buffer-name)))
722 (insert "<#part type=" type)
723 (insert " buffer=\"" bufname "\"")
724 (insert " disposition=\"inline\"")
725 (insert "><#/part>\n")
731 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
735 (webmail-netaddress-single-part)
736 (goto-char (point-max))
740 (narrow-to-region p (point-max))
741 (setq mime (webmail-netaddress-single-part))
743 (goto-char (point-min))
744 ;; Some blank line to seperate mails.
745 (insert "\n\nFrom nobody " (current-time-string) "\n")
747 (insert "Message-ID: <" id "@usa.net>\n"))
748 (unless (looking-at "$")
749 (if (search-forward "\n\n" nil t)
751 (webmail-error "article@2")))
753 (narrow-to-region (point-min) (point))
754 (goto-char (point-min))
756 (if (looking-at "MIME-Version\\|Content-Type")
757 (delete-region (point)
760 (if (re-search-forward "^[^ \t]" nil t)
761 (goto-char (match-beginning 0))
764 (goto-char (point-max))
766 (narrow-to-region (point) (point-max))
767 (insert "MIME-Version: 1.0\n"
770 (delete-region (point-min) (point-max))))
771 (goto-char (point-min))
773 (let (case-fold-search)
774 (while (re-search-forward "^From " nil t)
777 (mm-append-to-file (point-min) (point-max) file)))
781 (defun webmail-my-deja-open ()
782 (webmail-refresh-redirect)
783 (goto-char (point-min))
784 (if (re-search-forward "action=\"\\([^\"]+login_confirm\\.xp[^\"]+\\)\""
786 (setq webmail-aux (match-string 1))
787 (webmail-error "open@1")))
789 (defun webmail-my-deja-list ()
791 (goto-char (point-min))
792 (when (re-search-forward
793 "(\\([0-9]+\\) message(s), \\([0-9]+\\) new, \\([0-9]+\\) k )"
795 (message "Found %s mail(s), %s unread, total size %s K"
796 (match-string 1) (match-string 2) (match-string 3)))
797 (goto-char (point-min))
798 (while (re-search-forward
799 "• \\|\\(http:[^\"]+\\)/display_seemesg\\.femail\\?docid=\\([^&\"]+\\)"
801 (if (setq id (match-string 2))
802 (when (or newp (not webmail-newmail-only))
804 (cons id (format "%s/gmm_multiplex.femail?docid=%s&femail_page_name=display_page&bool_next_on_disp_pg=true&bool_prev_on_disp_pg=false&display_all_headers=false&%%2Fgmm_save.femail=Download&femail_page_name=display_page&bool_next_on_disp_pg=true&bool_prev_on_disp_pg=false&display_all_headers=false"
805 (match-string 1) id))
807 (setq webmail-aux (match-string 1))
810 (setq webmail-articles (nreverse webmail-articles))))
812 (defun webmail-my-deja-article (file id)
814 (goto-char (point-min))
815 (unless (re-search-forward "\\(http:[^\"]+/attachment/entire_message.txt[^\"]+\\)" nil t)
816 (webmail-error "article@1"))
817 (setq url (match-string 1))
819 (mm-with-unibyte-current-buffer
821 (goto-char (point-min))
822 (while (search-forward "\r\n" nil t)
823 (replace-match "\n"))
824 (goto-char (point-min))
825 (insert "\n\nFrom nobody " (current-time-string) "\n")
826 (mm-append-to-file (point-min) (point-max) file)))
830 ;;; webmail.el ends here