Importing Oort Gnus v0.03.
[elisp/gnus.git-] / lisp / webmail.el
1 ;;; webmail.el --- interface of web mail
2 ;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
5 ;; Keywords: hotmail netaddress my-deja netscape
6
7 ;; This file is part of GNU Emacs.
8
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.
13
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.
18
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.
23
24 ;;; Commentary:
25
26 ;; Note: Now mail.yahoo.com provides POP3 service, the webmail
27 ;; fetching is not going to be supported.
28
29 ;; Note: You need to have `url' and `w3' installed for this backend to
30 ;; work. `w3' must be 4.0pre46+one-line-cookie patch or standalone
31 ;; `url'.
32
33 ;; Todo: To support more web mail servers.
34
35 ;; Known bugs:
36 ;; 1. Net@ddress may corrupt `X-Face'.
37
38 ;; Warning:
39 ;; Webmail is an experimental function, which means NO WARRANTY.
40
41 ;;; Code:
42
43 (eval-when-compile (require 'cl))
44
45 (require 'nnoo)
46 (require 'message)
47 (require 'gnus-util)
48 (require 'gnus)
49 (require 'nnmail)
50 (require 'mm-util)
51 (require 'mml)
52 (eval-when-compile
53   (ignore-errors
54     (require 'w3)
55     (require 'url)
56     (require 'url-cookie)
57     (require 'w3-forms)
58     (require 'nnweb)))
59 ;; Report failure to find w3 at load time if appropriate.
60 (eval '(progn
61          (require 'w3)
62          (require 'url)
63          (require 'url-cookie)
64          (require 'w3-forms)
65          (require 'nnweb)))
66
67 ;;;
68
69 (defvar webmail-type-definition
70   '((hotmail
71      ;; Hotmail hate other HTTP user agents and use one line cookie
72      (paranoid agent cookie post)
73      (address . "www.hotmail.com")
74      (open-url "http://www.hotmail.com/")
75      (open-snarf . webmail-hotmail-open)
76      ;; W3 hate redirect POST
77      (login-url
78       "http://%s/cgi-bin/dologin?login=%s&passwd=%s&enter=Sign+in&sec=no&curmbox=ACTIVE&_lang=&js=yes&id=2&tw=-10000&beta="
79       webmail-aux user password)
80      ;;(login-snarf . webmail-hotmail-login)
81      ;;(list-url "%s" webmail-aux)
82      (list-snarf . webmail-hotmail-list)
83      (article-snarf . webmail-hotmail-article)
84      (trash-url
85       "%s&login=%s&f=33792&curmbox=ACTIVE&_lang=&foo=inbox&js=&page=&%s=on&_HMaction=MoveTo&tobox=trAsH&nullbox="
86       webmail-aux user id))
87     (yahoo
88      (paranoid agent cookie post)
89      (address . "mail.yahoo.com")
90      (open-url "http://mail.yahoo.com/")
91      (open-snarf . webmail-yahoo-open)
92      (login-url;; yahoo will not accept GET
93       content
94       ("%s" webmail-aux)
95       ".tries=&.src=ym&.last=&promo=&.intl=&.bypass=&.partner=&.chkP=Y&.done=&login=%s&passwd=%s"
96       user password)
97      (login-snarf . webmail-yahoo-login)
98      (list-url "%s&rb=Inbox&YN=1" webmail-aux)
99      (list-snarf . webmail-yahoo-list)
100      (article-snarf . webmail-yahoo-article)
101      (trash-url
102       "%s/ym/ShowFolder?YY=52107&inc=50&order=down&sort=date&pos=0&box=Inbox&DEL=Delete&destBox=&Mid=%s&destBox2="
103       webmail-aux id))
104     (netaddress
105      (paranoid cookie post)
106      (address . "www.netaddress.com")
107      (open-url "http://www.netaddress.com/")
108      (open-snarf . webmail-netaddress-open)
109      (login-url
110       content
111       ("%s" webmail-aux)
112       "LoginState=2&SuccessfulLogin=%%2Ftpl&NewServerName=www.netaddress.com&JavaScript=JavaScript1.2&DomainID=4&Domain=usa.net&NA31site=classic.netaddress.com&NA31port=80&UserID=%s&passwd=%s"
113       user password)
114      (login-snarf . webmail-netaddress-login)
115      (list-url
116       "http://www.netaddress.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True"
117       webmail-session)
118      (list-snarf . webmail-netaddress-list)
119      (article-url "http://www.netaddress.com/")
120      (article-snarf . webmail-netaddress-article)
121      (trash-url
122       "http://www.netaddress.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1"
123       webmail-session id))
124     (netscape
125      (paranoid cookie post agent)
126      (address . "webmail.netscape.com")
127      (open-url "http://ureg.netscape.com/iiop/UReg2/login/login?U2_LA=en&U2_BACK_FROM_CJ=true&U2_CS=iso-8859-1&U2_ENDURL=http://webmail.netscape.com/tpl/Subscribe/Step1&U2_NEW_ENDURL=http://webmail.netscape.com/tpl/Subscribe/Step1&U2_EXITURL=http://home.netscape.com/&U2_SOURCE=Webmail")
128      (open-snarf . webmail-netscape-open)
129      (login-url
130       content
131       ("http://ureg.netscape.com/iiop/UReg2/login/loginform")
132       "U2_USERNAME=%s&U2_PASSWORD=%s%s"
133       user password webmail-aux)
134      (login-snarf . webmail-netaddress-login)
135      (list-url
136       "http://webmail.netscape.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True"
137       webmail-session)
138      (list-snarf . webmail-netaddress-list)
139      (article-url "http://webmail.netscape.com/")
140      (article-snarf . webmail-netscape-article)
141      (trash-url
142       "http://webmail.netscape.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1"
143       webmail-session id))
144     (my-deja
145      (paranoid cookie post)
146      (address . "www.my-deja.com")
147      ;;(open-snarf . webmail-my-deja-open)
148      (login-url
149       content
150       ("http://mydeja.google.com/cgi-bin/deja/maillogin.py")
151       "userid=%s&password=%s"
152       user password)
153      (list-snarf . webmail-my-deja-list)
154      (article-snarf . webmail-my-deja-article)
155      (trash-url webmail-aux id))))
156
157 (defvar webmail-variables
158   '(address article-snarf article-url list-snarf list-url
159             login-url login-snarf open-url open-snarf site articles
160             post-process paranoid trash-url))
161
162 (defconst webmail-version "webmail 1.0")
163
164 (defvar webmail-newmail-only nil
165   "Only fetch new mails.")
166
167 (defvar webmail-move-to-trash-can t
168   "Move mail to trash can after fetch it.")
169
170 ;;; Internal variables
171
172 (defvar webmail-address nil)
173 (defvar webmail-paranoid nil)
174 (defvar webmail-aux nil)
175 (defvar webmail-session nil)
176 (defvar webmail-article-snarf nil)
177 (defvar webmail-article-url nil)
178 (defvar webmail-list-snarf nil)
179 (defvar webmail-list-url nil)
180 (defvar webmail-login-url nil)
181 (defvar webmail-login-snarf nil)
182 (defvar webmail-open-snarf nil)
183 (defvar webmail-open-url nil)
184 (defvar webmail-trash-url nil)
185 (defvar webmail-articles nil)
186 (defvar webmail-post-process nil)
187
188 (defvar webmail-buffer nil)
189 (defvar webmail-buffer-list nil)
190
191 (defvar webmail-type nil)
192
193 (defvar webmail-error-function nil)
194
195 (defvar webmail-debug-file "~/.emacs-webmail-debug")
196
197 ;;; Interface functions
198
199 (defun webmail-debug (str)
200   (with-temp-buffer
201     (insert "\n---------------- A bug at " str " ------------------\n")
202     (mapcar #'(lambda (sym)
203                 (if (boundp sym)
204                     (pp `(setq ,sym ',(eval sym)) (current-buffer))))
205             '(webmail-type user))
206     (insert "---------------- webmail buffer ------------------\n\n")
207     (insert-buffer-substring webmail-buffer)
208     (insert "\n---------------- end of buffer ------------------\n\n")
209     (append-to-file (point-min) (point-max) webmail-debug-file)))
210
211 (defun webmail-error (str)
212   (if webmail-error-function
213       (funcall webmail-error-function str))
214   (message "%s HTML has changed or your w3 package is too old.(%s)"
215            webmail-type str)
216   (error "%s HTML has changed or your w3 package is too old.(%s)"
217          webmail-type str))
218
219 (defun webmail-setdefault (type)
220   (let ((type-def (cdr (assq type webmail-type-definition)))
221         (vars webmail-variables)
222         pair)
223     (setq webmail-type type)
224     (dolist (var vars)
225       (if (setq pair (assq var type-def))
226           (set (intern (concat "webmail-" (symbol-name var))) (cdr pair))
227         (set (intern (concat "webmail-" (symbol-name var))) nil)))))
228
229 (defun webmail-encode-www-form-urlencoded (pairs)
230   "Return PAIRS encoded for forms."
231   (mapconcat
232    (function
233     (lambda (data)
234       (concat (w3-form-encode-xwfu (car data)) "="
235               (w3-form-encode-xwfu (cdr data)))))
236    pairs "&"))
237
238 (defun webmail-fetch-simple (url content)
239   (let ((url-request-data content)
240         (url-request-method "POST")
241         (url-request-extra-headers
242          '(("Content-type" . "application/x-www-form-urlencoded"))))
243     (nnweb-insert url))
244   t)
245
246 (defun webmail-fetch-form (url pairs)
247   (let ((url-request-data (webmail-encode-www-form-urlencoded pairs))
248         (url-request-method "POST")
249         (url-request-extra-headers
250          '(("Content-type" . "application/x-www-form-urlencoded"))))
251     (nnweb-insert url))
252   t)
253
254 (defun webmail-eval (expr)
255   (cond
256    ((consp expr)
257     (cons (webmail-eval (car expr)) (webmail-eval (cdr expr))))
258    ((symbolp expr)
259     (eval expr))
260    (t
261     expr)))
262
263 (defun webmail-url (xurl)
264   (mm-with-unibyte-current-buffer
265     (cond
266      ((eq (car xurl) 'content)
267       (pop xurl)
268       (webmail-fetch-simple (if (stringp (car xurl))
269                                 (car xurl)
270                               (apply 'format (webmail-eval (car xurl))))
271                             (apply 'format (webmail-eval (cdr xurl)))))
272      ((eq (car xurl) 'post)
273       (pop xurl)
274       (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
275      (t
276       (nnweb-insert (apply 'format (webmail-eval xurl)))))))
277
278 (defun webmail-init ()
279   "Initialize buffers and such."
280   (if (gnus-buffer-live-p webmail-buffer)
281       (set-buffer webmail-buffer)
282     (setq webmail-buffer
283           (nnheader-set-temp-buffer " *webmail*"))
284     (mm-disable-multibyte)))
285
286 (defvar url-package-name)
287 (defvar url-package-version)
288 (defvar url-cookie-multiple-line)
289 (defvar url-confirmation-func)
290
291 ;; Hack W3 POST redirect.  See `url-parse-mime-headers'.
292 ;;
293 ;; Netscape uses "GET" as redirect method when orignal method is POST
294 ;; and status is 302, .i.e no security risks by default without
295 ;; confirmation.
296 ;;
297 ;; Some web servers (at least Apache used by yahoo) return status 302
298 ;; instead of 303, though they mean 303.
299
300 (defun webmail-url-confirmation-func (prompt)
301   (cond
302    ((equal prompt (concat "Honor redirection with non-GET method "
303                           "(possible security risks)? "))
304     nil)
305    ((equal prompt "Continue (with method of GET)? ")
306     t)
307    (t (error prompt))))
308
309 (defun webmail-refresh-redirect ()
310   "Redirect refresh url in META."
311   (goto-char (point-min))
312   (while (re-search-forward
313           "<meta[ \t\r\n]*http-equiv=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
314           nil t)
315     (let ((url (match-string 1)))
316       (erase-buffer)
317       (mm-with-unibyte-current-buffer
318         (nnweb-insert url)))
319     (goto-char (point-min))))
320
321 (defun webmail-fetch (file subtype user password)
322   (save-excursion
323     (webmail-setdefault subtype)
324     (let ((url-package-name (if (memq 'agent webmail-paranoid)
325                                 "Mozilla"
326                               url-package-name))
327           (url-package-version (if (memq 'agent webmail-paranoid)
328                                    "4.0"
329                                  url-package-version))
330           (url-cookie-multiple-line (if (memq 'cookie webmail-paranoid)
331                                         nil
332                                       url-cookie-multiple-line))
333           (url-confirmation-func (if (memq 'post webmail-paranoid)
334                                      'webmail-url-confirmation-func
335                                    url-confirmation-func))
336           (url-http-silence-on-insecure-redirection t)
337           url-cookie-storage url-cookie-secure-storage
338           url-cookie-confirmation
339           item id (n 0))
340       (webmail-init)
341       (setq webmail-articles nil)
342       (when webmail-open-url
343         (erase-buffer)
344         (webmail-url webmail-open-url))
345       (if webmail-open-snarf (funcall webmail-open-snarf))
346       (when webmail-login-url
347         (erase-buffer)
348         (webmail-url webmail-login-url))
349       (if webmail-login-snarf
350           (funcall webmail-login-snarf))
351       (when webmail-list-url
352         (erase-buffer)
353         (webmail-url webmail-list-url))
354       (if webmail-list-snarf
355           (funcall webmail-list-snarf))
356       (while (setq item (pop webmail-articles))
357         (message "Fetching mail #%d..." (setq n (1+ n)))
358         (erase-buffer)
359         (mm-with-unibyte-current-buffer
360           (nnweb-insert (cdr item)))
361         (setq id (car item))
362         (if webmail-article-snarf
363             (funcall webmail-article-snarf file id))
364         (when (and webmail-trash-url webmail-move-to-trash-can)
365           (message "Move mail #%d to trash can..." n)
366           (condition-case err
367               (progn
368                 (webmail-url webmail-trash-url)
369                 (let (buf)
370                   (while (setq buf (pop webmail-buffer-list))
371                     (kill-buffer buf))))
372             (error
373              (let (buf)
374                (while (setq buf (pop webmail-buffer-list))
375                  (kill-buffer buf)))
376              (error err))))))
377     (if webmail-post-process
378         (funcall webmail-post-process))))
379
380 (defun webmail-encode-8bit ()
381   (goto-char (point-min))
382   (skip-chars-forward "^\200-\377")
383   (while (not (eobp))
384     (insert (format "&%d;" (mm-char-int (char-after))))
385     (delete-char 1)
386     (skip-chars-forward "^\200-\377")))
387
388 ;;; hotmail
389
390 (defun webmail-hotmail-open ()
391   (goto-char (point-min))
392   (if (re-search-forward
393        "action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t)
394       (setq webmail-aux (match-string 1))
395     (webmail-error "open@1")))
396
397 (defun webmail-hotmail-login ()
398   (let (site)
399     (goto-char (point-min))
400     (if (re-search-forward
401          "https?://\\([^/]+hotmail\\.msn\\.com\\)/cgi-bin/" nil t)
402         (setq site (match-string 1))
403       (webmail-error "login@1"))
404     (goto-char (point-min))
405     (if (re-search-forward
406          "\\(/cgi-bin/HoTMaiL\\?[^\"]*a=b[^\"]*\\)" nil t)
407         (setq webmail-aux (concat "http://" site (match-string 1)))
408       (webmail-error "login@2"))))
409
410 (defun webmail-hotmail-list ()
411   (goto-char (point-min))
412   (skip-chars-forward " \t\n\r")
413   (let (site url newp (total "0"))
414     (if (eobp)
415         (setq total "0")
416       (if (re-search-forward "\\([0-9]+\\) *<b>(\\([0-9]+\\) new)" nil t)
417           (message "Found %s (%s new)" (setq total (match-string 1))
418                    (match-string 2))
419         (if (re-search-forward "\\([0-9]+\\) new" nil t)
420             (message "Found %s new" (setq total (match-string 1)))
421           (webmail-error "list@0"))))
422     (unless (equal total "0")
423       (goto-char (point-min))
424       (if (re-search-forward
425          "https?://\\([^/]+hotmail\\.msn\\.com\\)/cgi-bin/" nil t)
426           (setq site (match-string 1))
427         (webmail-error "list@1"))
428       (goto-char (point-min))
429       (if (re-search-forward "disk=\\([^&]*\\)&" nil t)
430           (setq webmail-aux
431                 (concat "http://" site "/cgi-bin/HoTMaiL?disk="
432                         (match-string 1)))
433         (webmail-error "list@2"))
434       (goto-char (point-max))
435       (while (re-search-backward
436               "newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\""
437               nil t)
438         (if (setq url (match-string 1))
439             (progn
440               (if (or newp (not webmail-newmail-only))
441                   (let (id)
442                     (if (string-match "msg=\\([^&]+\\)" url)
443                         (setq id (match-string 1 url)))
444                     (push (cons id (concat "http://" site url "&raw=0"))
445                           webmail-articles)))
446               (setq newp nil))
447           (setq newp t))))))
448
449 ;; Thank victor@idaccr.org (Victor S. Miller) for raw=0
450
451 (defun webmail-hotmail-article (file id)
452   (goto-char (point-min))
453   (skip-chars-forward " \t\n\r")
454   (unless (eobp)
455     (if (not (search-forward "<pre>" nil t))
456         (webmail-error "article@3"))
457     (skip-chars-forward "\n\r\t ")
458     (delete-region (point-min) (point))
459     (if (not (search-forward "</pre>" nil t))
460         (webmail-error "article@3.1"))
461     (delete-region (match-beginning 0) (point-max))
462     (nnweb-remove-markup)
463     (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
464       (nnweb-decode-entities))
465     (goto-char (point-min))
466     (while (re-search-forward "\r\n?" nil t)
467       (replace-match "\n"))
468     (goto-char (point-min))
469     (insert "\n\n")
470     (if (not (looking-at "\n*From "))
471         (insert "From nobody " (current-time-string) "\n")
472       (forward-line))
473     (insert "X-Gnus-Webmail: " (symbol-value 'user)
474             "@" (symbol-name webmail-type) "\n")
475     (mm-append-to-file (point-min) (point-max) file)))
476
477 (defun webmail-hotmail-article-old (file id)
478   (let (p attachment count mime hotmail-direct)
479     (save-restriction
480       (webmail-encode-8bit)
481       (goto-char (point-min))
482       (if (not (search-forward "<DIV>" nil t))
483           (if (not (search-forward "Reply&nbsp;All" nil t))
484               (webmail-error "article@1")
485             (setq hotmail-direct t))
486         (goto-char (match-beginning 0)))
487       (narrow-to-region (point-min) (point))
488       (if (not (search-backward "<table" nil t 2))
489           (webmail-error "article@1.1"))
490       (delete-region (point-min) (match-beginning 0))
491       (while (search-forward "<a href=" nil t)
492         (setq p (match-beginning 0))
493         (search-forward "</a>" nil t)
494         (delete-region p (match-end 0)))
495       (nnweb-remove-markup)
496       (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
497         (nnweb-decode-entities))
498       (goto-char (point-min))
499       (delete-blank-lines)
500       (goto-char (point-min))
501       (when (search-forward "\n\n" nil t)
502         (backward-char)
503         (delete-region (point) (point-max)))
504       (goto-char (point-max))
505       (widen)
506       (insert "\n")
507       (setq p (point))
508       (while (re-search-forward
509               "<tt>\\|<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\""
510               nil t)
511         (if (setq attachment (match-string 1))
512             (let ((filename (match-string 2))
513                   bufname);; Attachment
514               (delete-region p (match-end 0))
515               (save-excursion
516                 (set-buffer (generate-new-buffer " *webmail-att*"))
517                 (nnweb-insert attachment)
518                 (push (current-buffer) webmail-buffer-list)
519                 (setq bufname (buffer-name)))
520               (setq mime t)
521               (insert "<#part type="
522                       (or (and filename
523                                (string-match "\\.[^\\.]+$" filename)
524                                (mailcap-extension-to-mime
525                                 (match-string 0 filename)))
526                           "application/octet-stream"))
527               (insert " buffer=\"" bufname "\"")
528               (insert " filename=\"" filename "\"")
529               (insert " disposition=\"inline\"")
530               (insert "><#/part>\n")
531               (setq p (point)))
532           (delete-region p (match-end 0))
533           (if hotmail-direct
534               (if (not (search-forward "</tt>" nil t))
535                   (webmail-error "article@1.2")
536                 (delete-region (match-beginning 0) (match-end 0)))
537             (setq count 1)
538             (while (and (> count 0)
539                         (re-search-forward "</div>\\|\\(<div>\\)" nil t))
540               (if (match-string 1)
541                   (setq count (1+ count))
542                 (if (= (setq count (1- count)) 0)
543                     (delete-region (match-beginning 0)
544                                    (match-end 0))))))
545           (narrow-to-region p (point))
546           (goto-char (point-min))
547           (cond
548            ((looking-at "<pre>")
549             (goto-char (match-end 0))
550             (if (looking-at "$") (forward-char))
551             (delete-region (point-min) (point))
552             (nnweb-remove-markup)
553             (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
554               (nnweb-decode-entities))
555             nil)
556            (t
557             (setq mime t)
558             (insert "<#part type=\"text/html\" disposition=inline>")
559             (goto-char (point-max))
560             (insert "<#/part>")))
561           (goto-char (point-max))
562           (setq p (point))
563           (widen)))
564       (delete-region p (point-max))
565       (goto-char (point-min))
566       ;; Some blank line to seperate mails.
567       (insert "\n\nFrom nobody " (current-time-string) "\n")
568       (insert "X-Gnus-Webmail: " (symbol-value 'user)
569               "@" (symbol-name webmail-type) "\n")
570       (if id
571           (insert (format "X-Message-ID: <%s@hotmail.com>\n" id)))
572       (unless (looking-at "$")
573         (if (search-forward "\n\n" nil t)
574             (forward-line -1)
575           (webmail-error "article@2")))
576       (narrow-to-region (point) (point-max))
577       (if mime
578           (insert "MIME-Version: 1.0\n"
579                   (prog1
580                       (mml-generate-mime)
581                     (delete-region (point-min) (point-max)))))
582       (goto-char (point-min))
583       (widen)
584       (let (case-fold-search)
585         (while (re-search-forward "^From " nil t)
586           (beginning-of-line)
587           (insert ">"))))
588     (mm-append-to-file (point-min) (point-max) file)))
589
590 ;;; yahoo
591
592 (defun webmail-yahoo-open ()
593   (goto-char (point-min))
594   (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
595       (setq webmail-aux (match-string 1))
596     (webmail-error "open@1")))
597
598 (defun webmail-yahoo-login ()
599   (goto-char (point-min))
600   (if (re-search-forward "http://[^/]+[0-9]\\.mail\\.yahoo\\.com/" nil t)
601       (setq webmail-aux (match-string 0))
602     (webmail-error "login@1"))
603   (if (re-search-forward "YY=[0-9]+" nil t)
604       (setq webmail-aux (concat webmail-aux "ym/ShowFolder?"
605                                 (match-string 0)))
606     (webmail-error "login@2")))
607
608 (defun webmail-yahoo-list ()
609   (let (url (newp t) (tofetch 0))
610     (goto-char (point-min))
611     (when (re-search-forward
612            "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
613       ;;(setq listed (match-string 1))
614       (message "Found %s mail(s)" (match-string 2)))
615     (if (string-match "http://[^/]+" webmail-aux)
616         (setq webmail-aux (match-string 0 webmail-aux))
617       (webmail-error "list@1"))
618     (goto-char (point-min))
619     (while (re-search-forward
620             "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
621             nil t)
622       (if (setq url (match-string 1))
623           (progn
624             (when (or newp (not webmail-newmail-only))
625               (push (cons (match-string 2) (concat webmail-aux url "&toc=1"))
626                     webmail-articles)
627               (setq tofetch (1+ tofetch)))
628             (setq newp t))
629         (setq newp nil)))
630     (setq webmail-articles (nreverse webmail-articles))
631     (message "Fetching %d mail(s)" tofetch)))
632
633 (defun webmail-yahoo-article (file id)
634   (let (p attachment)
635     (save-restriction
636       (goto-char (point-min))
637       (if (not (search-forward "value=\"Done\"" nil t))
638           (webmail-error "article@1"))
639       (if (not (search-forward "<table" nil t))
640           (webmail-error "article@2"))
641       (delete-region (point-min) (match-beginning 0))
642       (if (not (search-forward "</table>" nil t))
643           (webmail-error "article@3"))
644       (narrow-to-region (point-min) (match-end 0))
645       (while (search-forward "<a href=" nil t)
646         (setq p (match-beginning 0))
647         (search-forward "</a>" nil t)
648         (delete-region p (match-end 0)))
649       (nnweb-remove-markup)
650       (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
651         (nnweb-decode-entities))
652       (goto-char (point-min))
653       (delete-blank-lines)
654       (goto-char (point-max))
655       (widen)
656       (insert "\n")
657       (setq p (point))
658       (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
659         (setq attachment (match-string 0))
660         (let (bufname ct ctl cd description)
661           (if (not (search-forward "<table" nil t))
662               (webmail-error "article@4"))
663           (delete-region p (match-beginning 0))
664           (if (not (search-forward "</table>" nil t))
665               (webmail-error "article@5"))
666           (narrow-to-region p (match-end 0))
667           (nnweb-remove-markup)
668           (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
669             (nnweb-decode-entities))
670           (goto-char (point-min))
671           (delete-blank-lines)
672           (setq ct (mail-fetch-field "content-type")
673                 ctl (ignore-errors (mail-header-parse-content-type ct))
674                 ;;cte (mail-fetch-field "content-transfer-encoding")
675                 cd (mail-fetch-field "content-disposition")
676                 description (mail-fetch-field "content-description")
677                 id (mail-fetch-field "content-id"))
678           (delete-region (point-min) (point-max))
679           (widen)
680           (save-excursion
681             (set-buffer (generate-new-buffer " *webmail-att*"))
682             (nnweb-insert (concat webmail-aux attachment))
683             (push (current-buffer) webmail-buffer-list)
684             (setq bufname (buffer-name)))
685           (insert "<#part")
686           (if (and ctl (not (equal (car ctl) "text/")))
687               (insert " type=\"" (car ctl) "\""))
688           (insert " buffer=\"" bufname "\"")
689           (if cd
690               (insert " disposition=\"" cd "\""))
691           (if description
692               (insert " description=\"" description "\""))
693           (insert "><#/part>\n")
694           (setq p (point))))
695       (delete-region p (point-max))
696       (goto-char (point-min))
697       ;; Some blank line to seperate mails.
698       (insert "\n\nFrom nobody " (current-time-string) "\n")
699       (insert "X-Gnus-Webmail: " (symbol-value 'user)
700               "@" (symbol-name webmail-type) "\n")
701       (if id
702           (insert (format "X-Message-ID: <%s@yahoo.com>\n" id)))
703       (unless (looking-at "$")
704         (if (search-forward "\n\n" nil t)
705             (forward-line -1)
706           (webmail-error "article@2")))
707       (narrow-to-region (point) (point-max))
708       (insert "MIME-Version: 1.0\n"
709               (prog1
710                   (mml-generate-mime)
711                 (delete-region (point-min) (point-max))))
712       (goto-char (point-min))
713       (widen)
714       (let (case-fold-search)
715         (while (re-search-forward "^From " nil t)
716           (beginning-of-line)
717           (insert ">"))))
718     (mm-append-to-file (point-min) (point-max) file)))
719
720 ;;; netaddress
721
722 (defun webmail-netscape-open ()
723   (goto-char (point-min))
724   (setq webmail-aux "")
725   (while (re-search-forward
726           "TYPE=hidden *NAME=\\([^ ]+\\) *VALUE=\"\\([^\"]+\\)"
727           nil t)
728     (setq webmail-aux (concat webmail-aux "&" (match-string 1) "="
729                               (match-string 2)))))
730
731 (defun webmail-netaddress-open ()
732   (goto-char (point-min))
733   (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
734       (setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
735     (webmail-error "open@1")))
736
737 (defun webmail-netaddress-login ()
738   (webmail-refresh-redirect)
739   (goto-char (point-min))
740   (if (re-search-forward  "tpl/[^/]+/\\([^/]+\\)" nil t)
741       (setq webmail-session (match-string 1))
742     (webmail-error "login@1")))
743
744 (defun webmail-netaddress-list ()
745   (webmail-refresh-redirect)
746   (let (item id)
747     (goto-char (point-min))
748     (when (re-search-forward
749            "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t)
750       (message "Found %s mail(s), %s unread"
751                (match-string 2) (match-string 1)))
752     (goto-char (point-min))
753     (while (re-search-forward
754             "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
755       (if (setq id (match-string 2))
756           (setq item
757                 (cons id
758                       (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
759                               (car webmail-article-url)
760                               webmail-session id)))
761         (if (or (not webmail-newmail-only)
762                 (equal (match-string 1) "True"))
763             (push item webmail-articles))))
764     (setq webmail-articles (nreverse webmail-articles))))
765
766 (defun webmail-netaddress-single-part ()
767   (goto-char (point-min))
768   (cond
769    ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
770     ;; text/plain
771     (replace-match "")
772     (while (re-search-forward "[\t\040\r\n]+" nil t)
773       (replace-match " "))
774     (goto-char (point-min))
775     (while (re-search-forward "<br>" nil t)
776       (replace-match "\n"))
777     (nnweb-remove-markup)
778     (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
779       (nnweb-decode-entities))
780     nil)
781    (t
782     (insert "<#part type=\"text/html\" disposition=inline>")
783     (goto-char (point-max))
784     (insert "<#/part>")
785     t)))
786
787 (defun webmail-netaddress-article (file id)
788   (webmail-refresh-redirect)
789   (let (p p1 attachment count mime type)
790     (save-restriction
791       (webmail-encode-8bit)
792       (goto-char (point-min))
793       (if (not (search-forward "Trash" nil t))
794           (webmail-error "article@1"))
795       (if (not (search-forward "<form>" nil t))
796           (webmail-error "article@2"))
797       (delete-region (point-min) (match-beginning 0))
798       (if (not (search-forward "</form>" nil t))
799           (webmail-error "article@3"))
800       (narrow-to-region (point-min) (match-end 0))
801       (goto-char (point-min))
802       (while (re-search-forward "[\040\t\r\n]+" nil t)
803         (replace-match " "))
804       (goto-char (point-min))
805       (while (search-forward "<b>" nil t)
806         (replace-match "\n"))
807       (nnweb-remove-markup)
808       (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
809         (nnweb-decode-entities))
810       (goto-char (point-min))
811       (delete-blank-lines)
812       (goto-char (point-min))
813       (while (re-search-forward "^\040+\\|\040+$" nil t)
814         (replace-match ""))
815       (goto-char (point-min))
816       (while (re-search-forward "\040+" nil t)
817         (replace-match " "))
818       (goto-char (point-max))
819       (widen)
820       (insert "\n\n")
821       (setq p (point))
822       (unless (search-forward "<!-- Data -->" nil t)
823         (webmail-error "article@4"))
824       (forward-line 14)
825       (delete-region p (point))
826       (goto-char (point-max))
827       (unless (re-search-backward
828                "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
829         (webmail-error "article@5"))
830       (delete-region (point) (point-max))
831       (goto-char p)
832       (while (search-forward
833               "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
834               nil t 2)
835         (setq mime t)
836         (unless (search-forward "</TABLE>" nil t)
837           (webmail-error "article@6"))
838         (setq p1 (point))
839         (if (search-backward "<IMG " p t)
840             (progn
841               (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
842                 (webmail-error "article@7"))
843               (setq attachment (match-string 1))
844               (setq type (match-string 2))
845               (unless (search-forward "</TABLE>" nil t)
846                 (webmail-error "article@8"))
847               (delete-region p (point))
848               (let (bufname);; Attachment
849                 (save-excursion
850                   (set-buffer (generate-new-buffer " *webmail-att*"))
851                   (nnweb-insert (concat (car webmail-open-url) attachment))
852                   (push (current-buffer) webmail-buffer-list)
853                   (setq bufname (buffer-name)))
854                 (insert "<#part type=" type)
855                 (insert " buffer=\"" bufname "\"")
856                 (insert " disposition=\"inline\"")
857                 (insert "><#/part>\n")
858                 (setq p (point))))
859           (delete-region p p1)
860           (narrow-to-region
861            p
862            (if (search-forward
863                 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
864                 nil t)
865                (match-beginning 0)
866              (point-max)))
867           (webmail-netaddress-single-part)
868           (goto-char (point-max))
869           (setq p (point))
870           (widen)))
871       (unless mime
872         (narrow-to-region p (point-max))
873         (setq mime (webmail-netaddress-single-part))
874         (widen))
875       (goto-char (point-min))
876       ;; Some blank line to seperate mails.
877       (insert "\n\nFrom nobody " (current-time-string) "\n")
878       (insert "X-Gnus-Webmail: " (symbol-value 'user)
879               "@" (symbol-name webmail-type) "\n")
880       (if id
881           (insert (format "X-Message-ID: <%s@%s>\n" id webmail-address)))
882       (unless (looking-at "$")
883         (if (search-forward "\n\n" nil t)
884             (forward-line -1)
885           (webmail-error "article@2")))
886       (when mime
887         (narrow-to-region (point-min) (point))
888         (goto-char (point-min))
889         (while (not (eobp))
890           (if (looking-at "MIME-Version\\|Content-Type")
891               (delete-region (point)
892                              (progn
893                                (forward-line 1)
894                                (if (re-search-forward "^[^ \t]" nil t)
895                                    (goto-char (match-beginning 0))
896                                  (point-max))))
897             (forward-line 1)))
898         (goto-char (point-max))
899         (widen)
900         (narrow-to-region (point) (point-max))
901         (insert "MIME-Version: 1.0\n"
902                 (prog1
903                     (mml-generate-mime)
904                   (delete-region (point-min) (point-max))))
905         (goto-char (point-min))
906         (widen))
907       (let (case-fold-search)
908         (while (re-search-forward "^From " nil t)
909           (beginning-of-line)
910           (insert ">"))))
911     (mm-append-to-file (point-min) (point-max) file)))
912
913 (defun webmail-netscape-article (file id)
914   (let (p p1 attachment count mime type)
915     (save-restriction
916       (webmail-encode-8bit)
917       (goto-char (point-min))
918       (if (not (search-forward "Trash" nil t))
919           (webmail-error "article@1"))
920       (if (not (search-forward "<form>" nil t))
921           (webmail-error "article@2"))
922       (delete-region (point-min) (match-beginning 0))
923       (if (not (search-forward "</form>" nil t))
924           (webmail-error "article@3"))
925       (narrow-to-region (point-min) (match-end 0))
926       (goto-char (point-min))
927       (while (re-search-forward "[\040\t\r\n]+" nil t)
928         (replace-match " "))
929       (goto-char (point-min))
930       (while (re-search-forward "<a href=[^>]*>[^<]*</a>" nil t)
931         (replace-match ""))
932       (goto-char (point-min))
933       (while (search-forward "<b>" nil t)
934         (replace-match "\n"))
935       (nnweb-remove-markup)
936       (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
937         (nnweb-decode-entities))
938       (goto-char (point-min))
939       (delete-blank-lines)
940       (goto-char (point-min))
941       (while (re-search-forward "^\040+\\|\040+$" nil t)
942         (replace-match ""))
943       (goto-char (point-min))
944       (while (re-search-forward "\040+" nil t)
945         (replace-match " "))
946       (goto-char (point-max))
947       (widen)
948       (insert "\n\n")
949       (setq p (point))
950       (unless (search-forward "<!-- Data -->" nil t)
951         (webmail-error "article@4"))
952       (forward-line 14)
953       (delete-region p (point))
954       (goto-char (point-max))
955       (unless (re-search-backward
956                "<form name=\"Transfer2\"" p t)
957         (webmail-error "article@5"))
958       (delete-region (point) (point-max))
959       (goto-char p)
960       (while (search-forward
961               "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
962               nil t 2)
963         (setq mime t)
964         (unless (search-forward "</TABLE>" nil t)
965           (webmail-error "article@6"))
966         (setq p1 (point))
967         (if (search-backward "<IMG " p t)
968             (progn
969               (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
970                 (webmail-error "article@7"))
971               (setq attachment (match-string 1))
972               (setq type (match-string 2))
973               (unless (search-forward "</TABLE>" nil t)
974                 (webmail-error "article@8"))
975               (delete-region p (point))
976               (let (bufname);; Attachment
977                 (save-excursion
978                   (set-buffer (generate-new-buffer " *webmail-att*"))
979                   (nnweb-insert (concat (car webmail-open-url) attachment))
980                   (push (current-buffer) webmail-buffer-list)
981                   (setq bufname (buffer-name)))
982                 (insert "<#part type=" type)
983                 (insert " buffer=\"" bufname "\"")
984                 (insert " disposition=\"inline\"")
985                 (insert "><#/part>\n")
986                 (setq p (point))))
987           (delete-region p p1)
988           (narrow-to-region
989            p
990            (if (search-forward
991                 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
992                 nil t)
993                (match-beginning 0)
994              (point-max)))
995           (webmail-netaddress-single-part)
996           (goto-char (point-max))
997           (setq p (point))
998           (widen)))
999       (unless mime
1000         (narrow-to-region p (point-max))
1001         (setq mime (webmail-netaddress-single-part))
1002         (widen))
1003       (goto-char (point-min))
1004       ;; Some blank line to seperate mails.
1005       (insert "\n\nFrom nobody " (current-time-string) "\n")
1006       (insert "X-Gnus-Webmail: " (symbol-value 'user)
1007               "@" (symbol-name webmail-type) "\n")
1008       (if id
1009           (insert (format "X-Message-ID: <%s@%s>\n" id webmail-address)))
1010       (unless (looking-at "$")
1011         (if (search-forward "\n\n" nil t)
1012             (forward-line -1)
1013           (webmail-error "article@2")))
1014       (when mime
1015         (narrow-to-region (point-min) (point))
1016         (goto-char (point-min))
1017         (while (not (eobp))
1018           (if (looking-at "MIME-Version\\|Content-Type")
1019               (delete-region (point)
1020                              (progn
1021                                (forward-line 1)
1022                                (if (re-search-forward "^[^ \t]" nil t)
1023                                    (goto-char (match-beginning 0))
1024                                  (point-max))))
1025             (forward-line 1)))
1026         (goto-char (point-max))
1027         (widen)
1028         (narrow-to-region (point) (point-max))
1029         (insert "MIME-Version: 1.0\n"
1030                 (prog1
1031                     (mml-generate-mime)
1032                   (delete-region (point-min) (point-max))))
1033         (goto-char (point-min))
1034         (widen))
1035       (let (case-fold-search)
1036         (while (re-search-forward "^From " nil t)
1037           (beginning-of-line)
1038           (insert ">"))))
1039     (mm-append-to-file (point-min) (point-max) file)))
1040
1041 ;;; my-deja
1042
1043 (defun webmail-my-deja-open ()
1044   (webmail-refresh-redirect)
1045   (goto-char (point-min))
1046   (if (re-search-forward "action=\"\\([^\"]+maillogin\\.py[^\"]*\\)\""
1047                          nil t)
1048       (setq webmail-aux (match-string 1))
1049     (webmail-error "open@1")))
1050
1051 (defun webmail-my-deja-list ()
1052   (let (item id newp base)
1053     (goto-char (point-min))
1054     (when (re-search-forward "href=\"\\(\\([^\"]*\\)/mailnf\\.[^\"]*\\)\""
1055                              nil t)
1056       (let ((url (match-string 1)))
1057         (setq base (match-string 2))
1058         (erase-buffer)
1059         (nnweb-insert url)))
1060     (goto-char (point-min))
1061     (when (re-search-forward
1062            "(\\([0-9]+\\) Message.?-[^>]*\\([0-9]+\\) New"
1063            nil t)
1064       (message "Found %s mail(s), %s unread"
1065                (match-string 1) (match-string 2)))
1066     (goto-char (point-min))
1067     (while (re-search-forward
1068             "newmail\\.gif\\|href=\"[^\"]*\\(mailnf\\.[^\"]+act=view[^\"]+mid=\\([^\"&]+\\)[^\"]+\\)\""
1069             nil t)
1070       (if (setq id (match-string 2))
1071           (when (and (or newp (not webmail-newmail-only))
1072                      (not (assoc id webmail-articles)))
1073             (push (cons id (setq webmail-aux
1074                                  (concat base "/" (match-string 1))))
1075                   webmail-articles)
1076             (setq newp nil))
1077         (setq newp t)))
1078     (setq webmail-articles (nreverse webmail-articles))))
1079
1080 (defun webmail-my-deja-article-part (base)
1081   (let (p)
1082     (cond
1083      ((looking-at "[\t\040\r\n]*<!--[^>]*>")
1084       (replace-match ""))
1085      ((looking-at "[\t\040\r\n]*</PRE>")
1086       (replace-match ""))
1087      ((looking-at "[\t\040\r\n]*<PRE>")
1088       ;; text/plain
1089       (replace-match "")
1090       (save-restriction
1091         (narrow-to-region (point)
1092                           (if (re-search-forward "</?PRE>" nil t)
1093                               (match-beginning 0)
1094                             (point-max)))
1095         (goto-char (point-min))
1096         (nnweb-remove-markup)
1097         (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
1098           (nnweb-decode-entities))
1099         (goto-char (point-max))))
1100      ((looking-at "[\t\040\r\n]*<TABLE")
1101       (save-restriction
1102         (narrow-to-region (point)
1103                           (if (search-forward "</TABLE>" nil t 2)
1104                               (point)
1105                             (point-max)))
1106         (goto-char (point-min))
1107         (let (name type url bufname)
1108           (if (and (search-forward "File Name:" nil t)
1109                    (re-search-forward "<FONT[^>]+>\\([^<]+\\)" nil t))
1110               (setq name (match-string 1)))
1111           (if (and (search-forward "File Type:" nil t)
1112                    (re-search-forward "<FONT[^>]+>\\([^<]+\\)" nil t))
1113               (setq type (match-string 1)))
1114           (unless (re-search-forward "action=\"getattach\\.cgi/\\([^\"]+\\)"
1115                                      nil t)
1116             (webmail-error "article@5"))
1117           (setq url (concat base "/getattach.cgi/" (match-string 1)
1118                             "?sm=Download"))
1119           (while (re-search-forward
1120                   "type=hidden name=\"\\([^\"]+\\)\" value=\"\\([^\"]+\\)"
1121                   nil t)
1122             (setq url (concat url "&" (match-string 1) "="
1123                                   (match-string 2))))
1124           (delete-region (point-min) (point-max))
1125           (save-excursion
1126             (set-buffer (generate-new-buffer " *webmail-att*"))
1127             (nnweb-insert url)
1128             (push (current-buffer) webmail-buffer-list)
1129             (setq bufname (buffer-name)))
1130           (insert "<#part type=\"" type "\"")
1131           (if name (insert " filename=\"" name "\""))
1132           (insert " buffer=\"" bufname "\"")
1133           (insert " disposition=inline><#/part>"))))
1134      (t
1135       (insert "<#part type=\"text/html\" disposition=inline>")
1136       (goto-char (point-max))
1137       (insert "<#/part>")))))
1138
1139 (defun webmail-my-deja-article (file id)
1140   (let (base)
1141     (goto-char (point-min))
1142     (unless (string-match "\\([^\"]+\\)/mail" webmail-aux)
1143       (webmail-error "article@0"))
1144     (setq base (match-string 1 webmail-aux))
1145     (when (re-search-forward
1146            "href=\"[^\"]*\\(mailnf\\.[^\"]+act=move[^\"]+mid=\\([^\"&]+\\)[^\"]+\\)\""
1147            nil t)
1148       (setq webmail-aux (concat base "/" (match-string 1)))
1149       (string-match "mid=[^\"&]+" webmail-aux)
1150       (setq webmail-aux (replace-match "mid=%s" nil nil webmail-aux)))
1151     (unless (search-forward "<HR noshade>" nil t)
1152       (webmail-error "article@1"))
1153     (delete-region (point-min) (point))
1154     (unless (search-forward "<HR noshade>" nil t)
1155       (webmail-error "article@2"))
1156     (save-restriction
1157       (narrow-to-region (point-min) (point))
1158       (while (search-forward "\r\n" nil t)
1159         (replace-match "\n"))
1160       (nnweb-remove-markup)
1161       (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities)))
1162         (nnweb-decode-entities))
1163       (goto-char (point-min))
1164       (while (re-search-forward "\n\n+" nil t)
1165         (replace-match "\n"))
1166       (goto-char (point-max)))
1167     (save-restriction
1168       (narrow-to-region (point) (point-max))
1169       (goto-char (point-max))
1170       (unless (search-backward "<HR noshade>" nil t)
1171         (webmail-error "article@3"))
1172       (unless (search-backward "</TT>" nil t)
1173         (webmail-error "article@4"))
1174       (delete-region (point) (point-max))
1175       (goto-char (point-min))
1176       (while (not (eobp))
1177         (webmail-my-deja-article-part base))
1178       (insert "MIME-Version: 1.0\n"
1179               (prog1
1180                   (mml-generate-mime)
1181                 (delete-region (point-min) (point-max)))))
1182     (goto-char (point-min))
1183     (insert "\n\nFrom nobody " (current-time-string) "\n")
1184     (insert "X-Gnus-Webmail: " (symbol-value 'user)
1185             "@" (symbol-name webmail-type) "\n")
1186     (if (eq (char-after) ?\n)
1187         (delete-char 1))
1188     (mm-append-to-file (point-min) (point-max) file)))
1189
1190 (provide 'webmail)
1191
1192 ;;; webmail.el ends here