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 (message "%s HTML has changed; please get a new version of webmail (%s)"
176 (error "%s HTML has changed; please get a new version of webmail (%s)"
179 (defun webmail-setdefault (type)
180 (let ((type-def (cdr (assq type webmail-type-definition)))
181 (vars webmail-variables)
183 (setq webmail-type type)
185 (if (setq pair (assq var type-def))
186 (set (intern (concat "webmail-" (symbol-name var))) (cdr pair))
187 (set (intern (concat "webmail-" (symbol-name var))) nil)))))
189 (defun webmail-encode-www-form-urlencoded (pairs)
190 "Return PAIRS encoded for forms."
194 (concat (w3-form-encode-xwfu (car data)) "="
195 (w3-form-encode-xwfu (cdr data)))))
198 (defun webmail-fetch-simple (url content)
199 (let ((url-request-data content)
200 (url-request-method "POST")
201 (url-request-extra-headers
202 '(("Content-type" . "application/x-www-form-urlencoded"))))
206 (defun webmail-fetch-form (url pairs)
207 (let ((url-request-data (webmail-encode-www-form-urlencoded pairs))
208 (url-request-method "POST")
209 (url-request-extra-headers
210 '(("Content-type" . "application/x-www-form-urlencoded"))))
214 (defun webmail-eval (expr)
217 (cons (webmail-eval (car expr)) (webmail-eval (cdr expr))))
223 (defun webmail-url (xurl)
224 (mm-with-unibyte-current-buffer
226 ((eq (car xurl) 'content)
228 (webmail-fetch-simple (if (stringp (car xurl))
230 (apply 'format (webmail-eval (car xurl))))
231 (apply 'format (webmail-eval (cdr xurl)))))
232 ((eq (car xurl) 'post)
234 (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
236 (nnweb-insert (apply 'format (webmail-eval xurl)))))))
238 (defun webmail-init ()
239 "Initialize buffers and such."
240 (if (gnus-buffer-live-p webmail-buffer)
241 (set-buffer webmail-buffer)
244 (nnheader-set-temp-buffer " *webmail*")))))
246 (defvar url-package-name)
247 (defvar url-package-version)
248 (defvar url-cookie-multiple-line)
249 (defvar url-confirmation-func)
251 ;; Hack W3 POST redirect. See `url-parse-mime-headers'.
253 ;; Netscape uses "GET" as redirect method when orignal method is POST
254 ;; and status is 302, .i.e no security risks by default without
257 ;; Some web servers (at least Apache used by yahoo) return status 302
258 ;; instead of 303, though they mean 303.
260 (defun webmail-url-confirmation-func (prompt)
262 ((equal prompt (concat "Honor redirection with non-GET method "
263 "(possible security risks)? "))
265 ((equal prompt "Continue (with method of GET)? ")
269 (defun webmail-refresh-redirect ()
270 "Redirect refresh url in META."
271 (goto-char (point-min))
272 (while (re-search-forward
273 "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
275 (let ((url (match-string 1)))
277 (mm-with-unibyte-current-buffer
279 (goto-char (point-min))))
281 (defun webmail-fetch (file subtype user password)
283 (webmail-setdefault subtype)
284 (let ((url-package-name (if (memq 'agent webmail-paranoid)
287 (url-package-version (if (memq 'agent webmail-paranoid)
289 url-package-version))
290 (url-cookie-multiple-line (if (memq 'cookie webmail-paranoid)
292 url-cookie-multiple-line))
293 (url-confirmation-func (if (memq 'post webmail-paranoid)
294 'webmail-url-confirmation-func
295 url-confirmation-func))
296 url-cookie-storage url-cookie-secure-storage
297 url-cookie-confirmation
300 (setq webmail-articles nil)
301 (when webmail-open-url
303 (webmail-url webmail-open-url))
304 (if webmail-open-snarf (funcall webmail-open-snarf))
305 (when webmail-login-url
307 (webmail-url webmail-login-url))
308 (if webmail-login-snarf
309 (funcall webmail-login-snarf))
310 (when webmail-list-url
312 (webmail-url webmail-list-url))
313 (if webmail-list-snarf
314 (funcall webmail-list-snarf))
315 (while (setq item (pop webmail-articles))
316 (message "Fetching mail #%d..." (setq n (1+ n)))
318 (mm-with-unibyte-current-buffer
319 (nnweb-insert (cdr item)))
321 (if webmail-article-snarf
322 (funcall webmail-article-snarf file id))
323 (when (and webmail-trash-url webmail-move-to-trash-can)
324 (message "Move mail #%d to trash can..." n)
327 (webmail-url webmail-trash-url)
329 (while (setq buf (pop webmail-buffer-list))
333 (while (setq buf (pop webmail-buffer-list))
336 (if webmail-post-process
337 (funcall webmail-post-process))))
339 (defun webmail-encode-8bit ()
340 (goto-char (point-min))
341 (skip-chars-forward "^\200-\377")
343 (insert (format "&%d;" (mm-char-int (char-after))))
345 (skip-chars-forward "^\200-\377")))
349 (defun webmail-hotmail-open ()
350 (goto-char (point-min))
351 (if (re-search-forward
352 "action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t)
353 (setq webmail-aux (match-string 1))
354 (webmail-error "open@1")))
356 (defun webmail-hotmail-list ()
358 (goto-char (point-min))
359 (if (re-search-forward "[0-9]+ messages, [0-9]+ new" nil t)
360 (message "Found %s" (match-string 0))
361 (webmail-error "maybe your w3 version is too old"))
362 (goto-char (point-min))
363 (if (re-search-forward
364 "action=\"https?://\\([^/]+\\)/cgi-bin/HoTMaiL" nil t)
365 (setq site (match-string 1))
366 (webmail-error "list@1"))
367 (goto-char (point-min))
368 (if (re-search-forward "disk=\\([^&]+\\)&" nil t)
370 (concat "http://" site "/cgi-bin/HoTMaiL?disk="
372 (webmail-error "list@2"))
373 (goto-char (point-max))
374 (while (re-search-backward
375 "newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\""
377 (if (setq url (match-string 1))
379 (if (or newp (not webmail-newmail-only))
381 (if (string-match "msg=\\([^&]+\\)" url)
382 (setq id (match-string 1 url)))
383 (push (cons id (concat "http://" site url))
388 (defun webmail-hotmail-article (file id)
389 (let (p attachment count mime hotmail-direct)
391 (webmail-encode-8bit)
392 (goto-char (point-min))
393 (if (not (search-forward "<DIV>" nil t))
394 (if (not (search-forward "Reply All" nil t))
395 (webmail-error "article@1")
396 (setq hotmail-direct t))
397 (goto-char (match-beginning 0)))
398 (narrow-to-region (point-min) (point))
399 (if (not (search-backward "<table" nil t 2))
400 (webmail-error "article@1.1"))
401 (delete-region (point-min) (match-beginning 0))
402 (while (search-forward "<a href=" nil t)
403 (setq p (match-beginning 0))
404 (search-forward "</a>" nil t)
405 (delete-region p (match-end 0)))
406 (nnweb-remove-markup)
407 (nnweb-decode-entities)
408 (goto-char (point-min))
410 (goto-char (point-min))
411 (when (search-forward "\n\n" nil t)
413 (delete-region (point) (point-max)))
414 (goto-char (point-max))
418 (while (re-search-forward
419 "<tt>\\|<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\""
421 (if (setq attachment (match-string 1))
422 (let ((filename (match-string 2))
423 bufname);; Attachment
424 (delete-region p (match-end 0))
426 (set-buffer (generate-new-buffer " *webmail-att*"))
427 (nnweb-insert attachment)
428 (push (current-buffer) webmail-buffer-list)
429 (setq bufname (buffer-name)))
431 (insert "<#part type="
433 (string-match "\\.[^\\.]+$" filename)
434 (mailcap-extension-to-mime
435 (match-string 0 filename)))
436 "application/octet-stream"))
437 (insert " buffer=\"" bufname "\"")
438 (insert " filename=\"" filename "\"")
439 (insert " disposition=\"inline\"")
440 (insert "><#/part>\n")
442 (delete-region p (match-end 0))
444 (if (not (search-forward "</tt>" nil t))
445 (webmail-error "article@1.2")
446 (delete-region (match-beginning 0) (match-end 0)))
448 (while (and (> count 0)
449 (re-search-forward "</div>\\|\\(<div>\\)" nil t))
451 (setq count (1+ count))
452 (if (= (setq count (1- count)) 0)
453 (delete-region (match-beginning 0)
455 (narrow-to-region p (point))
456 (goto-char (point-min))
458 ((looking-at "<pre>")
459 (goto-char (match-end 0))
460 (if (looking-at "$") (forward-char))
461 (delete-region (point-min) (point))
462 (nnweb-remove-markup)
463 (nnweb-decode-entities)
467 (insert "<#part type=\"text/html\" disposition=inline>")
468 (goto-char (point-max))
469 (insert "<#/part>")))
470 (goto-char (point-max))
473 (delete-region p (point-max))
474 (goto-char (point-min))
475 ;; Some blank line to seperate mails.
476 (insert "\n\nFrom nobody " (current-time-string) "\n")
478 (insert (format "Message-ID: <%s@hotmail.com>\n" id)))
479 (unless (looking-at "$")
480 (if (search-forward "\n\n" nil t)
482 (webmail-error "article@2")))
483 (narrow-to-region (point) (point-max))
485 (insert "MIME-Version: 1.0\n"
488 (delete-region (point-min) (point-max)))))
489 (goto-char (point-min))
491 (let (case-fold-search)
492 (while (re-search-forward "^From " nil t)
495 (mm-append-to-file (point-min) (point-max) file)))
499 (defun webmail-yahoo-open ()
500 (goto-char (point-min))
501 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
502 (setq webmail-aux (match-string 1))
503 (webmail-error "open@1")))
505 (defun webmail-yahoo-login ()
506 (goto-char (point-min))
507 (if (re-search-forward "http://[a-zA-Z][0-9]\\.mail\\.yahoo\\.com/" nil t)
508 (setq webmail-aux (match-string 0))
509 (webmail-error "login@1"))
510 (if (re-search-forward "YY=[0-9]+" nil t)
511 (setq webmail-aux (concat webmail-aux "ym/us/ShowFolder?"
513 (webmail-error "login@2")))
515 (defun webmail-yahoo-list ()
516 (let (url (newp t) (tofetch 0))
517 (goto-char (point-min))
518 (when (re-search-forward
519 "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
520 ;;(setq listed (match-string 1))
521 (message "Found %s mail(s)" (match-string 2)))
522 (if (string-match "http://[^/]+" webmail-aux)
523 (setq webmail-aux (match-string 0 webmail-aux))
524 (webmail-error "list@1"))
525 (goto-char (point-min))
526 (while (re-search-forward
527 "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/us/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
529 (if (setq url (match-string 1))
531 (when (or newp (not webmail-newmail-only))
532 (push (cons (match-string 2) (concat webmail-aux url "&toc=1"))
534 (setq tofetch (1+ tofetch)))
537 (setq webmail-articles (nreverse webmail-articles))
538 (message "Fetching %d mail(s)" tofetch)))
540 (defun webmail-yahoo-article (file id)
543 (goto-char (point-min))
544 (if (not (search-forward "value=\"Done\"" nil t))
545 (webmail-error "article@1"))
546 (if (not (search-forward "<table" nil t))
547 (webmail-error "article@2"))
548 (delete-region (point-min) (match-beginning 0))
549 (if (not (search-forward "</table>" nil t))
550 (webmail-error "article@3"))
551 (narrow-to-region (point-min) (match-end 0))
552 (while (search-forward "<a href=" nil t)
553 (setq p (match-beginning 0))
554 (search-forward "</a>" nil t)
555 (delete-region p (match-end 0)))
556 (nnweb-remove-markup)
557 (nnweb-decode-entities)
558 (goto-char (point-min))
560 (goto-char (point-max))
564 (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
565 (setq attachment (match-string 0))
566 (let (bufname ct ctl cd description)
567 (if (not (search-forward "<table" nil t))
568 (webmail-error "article@4"))
569 (delete-region p (match-beginning 0))
570 (if (not (search-forward "</table>" nil t))
571 (webmail-error "article@5"))
572 (narrow-to-region p (match-end 0))
573 (nnweb-remove-markup)
574 (nnweb-decode-entities)
575 (goto-char (point-min))
577 (setq ct (mail-fetch-field "content-type")
578 ctl (ignore-errors (mail-header-parse-content-type ct))
579 ;;cte (mail-fetch-field "content-transfer-encoding")
580 cd (mail-fetch-field "content-disposition")
581 description (mail-fetch-field "content-description")
582 id (mail-fetch-field "content-id"))
583 (delete-region (point-min) (point-max))
586 (set-buffer (generate-new-buffer " *webmail-att*"))
587 (nnweb-insert (concat webmail-aux attachment))
588 (push (current-buffer) webmail-buffer-list)
589 (setq bufname (buffer-name)))
591 (if (and ctl (not (equal (car ctl) "text/")))
592 (insert " type=\"" (car ctl) "\""))
593 (insert " buffer=\"" bufname "\"")
595 (insert " disposition=\"" cd "\""))
597 (insert " description=\"" description "\""))
598 (insert "><#/part>\n")
600 (delete-region p (point-max))
601 (goto-char (point-min))
602 ;; Some blank line to seperate mails.
603 (insert "\n\nFrom nobody " (current-time-string) "\n")
605 (insert (format "Message-ID: <%s@yahoo.com>\n" id)))
606 (unless (looking-at "$")
607 (if (search-forward "\n\n" nil t)
609 (webmail-error "article@2")))
610 (narrow-to-region (point) (point-max))
611 (insert "MIME-Version: 1.0\n"
614 (delete-region (point-min) (point-max))))
615 (goto-char (point-min))
617 (let (case-fold-search)
618 (while (re-search-forward "^From " nil t)
621 (mm-append-to-file (point-min) (point-max) file)))
625 (defun webmail-netaddress-open ()
626 (goto-char (point-min))
627 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
628 (setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
629 (webmail-error "open@1")))
631 (defun webmail-netaddress-login ()
632 (webmail-refresh-redirect)
633 (goto-char (point-min))
634 (if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t)
635 (setq webmail-session (match-string 1))
636 (webmail-error "login@1")))
638 (defun webmail-netaddress-list ()
640 (goto-char (point-min))
641 (when (re-search-forward
642 "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t)
643 (message "Found %s mail(s), %s unread"
644 (match-string 2) (match-string 1)))
645 (goto-char (point-min))
646 (while (re-search-forward
647 "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
648 (if (setq id (match-string 2))
651 (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
652 (car webmail-open-url)
653 webmail-session id)))
654 (if (or (not webmail-newmail-only)
655 (equal (match-string 1) "True"))
656 (push item webmail-articles))))
657 (setq webmail-articles (nreverse webmail-articles))))
659 (defun webmail-netaddress-single-part ()
660 (goto-char (point-min))
662 ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
665 (while (re-search-forward "[\t\040\r\n]+" nil t)
667 (goto-char (point-min))
668 (while (re-search-forward "<br>" nil t)
669 (replace-match "\n"))
670 (nnweb-remove-markup)
671 (nnweb-decode-entities)
674 (insert "<#part type=\"text/html\" disposition=inline>")
675 (goto-char (point-max))
679 (defun webmail-netaddress-article (file id)
680 (let (p p1 attachment count mime type)
682 (webmail-encode-8bit)
683 (goto-char (point-min))
684 (if (not (search-forward "Trash" nil t))
685 (webmail-error "article@1"))
686 (if (not (search-forward "<form>" nil t))
687 (webmail-error "article@2"))
688 (delete-region (point-min) (match-beginning 0))
689 (if (not (search-forward "</form>" nil t))
690 (webmail-error "article@3"))
691 (narrow-to-region (point-min) (match-end 0))
692 (goto-char (point-min))
693 (while (re-search-forward "[\040\t\r\n]+" nil t)
695 (goto-char (point-min))
696 (while (search-forward "<b>" nil t)
697 (replace-match "\n"))
698 (nnweb-remove-markup)
699 (nnweb-decode-entities)
700 (goto-char (point-min))
702 (goto-char (point-min))
703 (while (re-search-forward "^\040+\\|\040+$" nil t)
705 (goto-char (point-min))
706 (while (re-search-forward "\040+" nil t)
708 (goto-char (point-max))
712 (unless (search-forward "<!-- Data -->" nil t)
713 (webmail-error "article@4"))
715 (delete-region p (point))
716 (goto-char (point-max))
717 (unless (re-search-backward
718 "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
719 (webmail-error "article@5"))
720 (delete-region (point) (point-max))
722 (while (search-forward
723 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
726 (unless (search-forward "</TABLE>" nil t)
727 (webmail-error "article@6"))
729 (if (search-backward "<IMG " p t)
731 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
732 (webmail-error "article@7"))
733 (setq attachment (match-string 1))
734 (setq type (match-string 2))
735 (unless (search-forward "</TABLE>" nil t)
736 (webmail-error "article@8"))
737 (delete-region p (point))
738 (let (bufname);; Attachment
740 (set-buffer (generate-new-buffer " *webmail-att*"))
741 (nnweb-insert (concat (car webmail-open-url) attachment))
742 (push (current-buffer) webmail-buffer-list)
743 (setq bufname (buffer-name)))
744 (insert "<#part type=" type)
745 (insert " buffer=\"" bufname "\"")
746 (insert " disposition=\"inline\"")
747 (insert "><#/part>\n")
753 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
757 (webmail-netaddress-single-part)
758 (goto-char (point-max))
762 (narrow-to-region p (point-max))
763 (setq mime (webmail-netaddress-single-part))
765 (goto-char (point-min))
766 ;; Some blank line to seperate mails.
767 (insert "\n\nFrom nobody " (current-time-string) "\n")
769 (insert (format "Message-ID: <%s@usa.net>\n" id)))
770 (unless (looking-at "$")
771 (if (search-forward "\n\n" nil t)
773 (webmail-error "article@2")))
775 (narrow-to-region (point-min) (point))
776 (goto-char (point-min))
778 (if (looking-at "MIME-Version\\|Content-Type")
779 (delete-region (point)
782 (if (re-search-forward "^[^ \t]" nil t)
783 (goto-char (match-beginning 0))
786 (goto-char (point-max))
788 (narrow-to-region (point) (point-max))
789 (insert "MIME-Version: 1.0\n"
792 (delete-region (point-min) (point-max))))
793 (goto-char (point-min))
795 (let (case-fold-search)
796 (while (re-search-forward "^From " nil t)
799 (mm-append-to-file (point-min) (point-max) file)))
803 (defun webmail-my-deja-open ()
804 (webmail-refresh-redirect)
805 (goto-char (point-min))
806 (if (re-search-forward "action=\"\\([^\"]+login_confirm\\.xp[^\"]+\\)\""
808 (setq webmail-aux (match-string 1))
809 (webmail-error "open@1")))
811 (defun webmail-my-deja-list ()
813 (goto-char (point-min))
814 (when (re-search-forward
815 "(\\([0-9]+\\) message(s), \\([0-9]+\\) new, \\([0-9]+\\) k )"
817 (message "Found %s mail(s), %s unread, total size %s K"
818 (match-string 1) (match-string 2) (match-string 3)))
819 (goto-char (point-min))
820 (while (re-search-forward
821 "• \\|\\(http:[^\"]+\\)/display_seemesg\\.femail\\?docid=\\([^&\"]+\\)"
823 (if (setq id (match-string 2))
824 (when (or newp (not webmail-newmail-only))
826 (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"
827 (match-string 1) id))
829 (setq webmail-aux (match-string 1))
832 (setq webmail-articles (nreverse webmail-articles))))
834 (defun webmail-my-deja-article (file id)
836 (goto-char (point-min))
837 (unless (re-search-forward "\\(http:[^\"]+/attachment/entire_message.txt[^\"]+\\)" nil t)
838 (webmail-error "article@1"))
839 (setq url (match-string 1))
841 (mm-with-unibyte-current-buffer
843 (goto-char (point-min))
844 (while (search-forward "\r\n" nil t)
845 (replace-match "\n"))
846 (goto-char (point-min))
847 (insert "\n\nFrom nobody " (current-time-string) "\n")
848 (mm-append-to-file (point-min) (point-max) file)))
852 ;;; webmail.el ends here