1 ;;; webmail.el --- interfacing with web mail
2 ;; Copyright (C) 1999 Free Software Foundation, Inc.
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
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
29 ;; Todo: To support more web mail servers.
32 ;; 1. In w3, there are two copies of url-maybe-relative.
33 ;; If it is loaded from w3.el, (load-library "url").
34 ;; Fixed in w3 4.0pre46.
35 ;; 2. Hotmail only accept one line cookie, while w3 breaks cookies
37 ;; Maybe fixed in w3 4.0pre47+?.
38 ;; 3. Net@ddress may corrupt `X-Face'.
41 ;; Webmail is an experimental function, which means NO WARRANTY.
45 (eval-when-compile (require 'cl))
60 ;; Report failure to find w3 at load time if appropriate.
69 (defvar webmail-type-definition
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
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 (list-snarf . webmail-hotmail-list)
81 (article-snarf . webmail-hotmail-article)
83 "%s&login=%s&f=33792&curmbox=ACTIVE&_lang=&js=&foo=inbox&page=&%s=on&Move+To.x=Move+To&tobox=trAsH"
86 (paranoid cookie post)
87 (address . "mail.yahoo.com")
88 (open-url "http://mail.yahoo.com")
89 (open-snarf . webmail-yahoo-open)
90 (login-url ;; yahoo will not accept GET
93 ".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"
95 (login-snarf . webmail-yahoo-login)
96 (list-url "%s&rb=Inbox&YN=1" webmail-aux)
97 (list-snarf . webmail-yahoo-list)
98 (article-snarf . webmail-yahoo-article)
100 "%s/ym/us/ShowFolder?YY=52107&inc=50&order=down&sort=date&pos=0&box=Inbox&DEL=Delete&destBox=&Mid=%s&destBox2="
103 (paranoid cookie post)
104 (address . "www.netaddress.com")
105 (open-url "http://www.netaddress.com")
106 (open-snarf . webmail-netaddress-open)
107 (login-url ;; yahoo will not accept GET
110 "LoginState=2&SuccessfulLogin=%%2Ftpl&NewServerName=www.netaddress.com&JavaScript=JavaScript1.2&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=%s&passwd=%s"
112 (login-snarf . webmail-netaddress-login)
114 "http://www.netaddress.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True"
116 (list-snarf . webmail-netaddress-list)
117 (article-snarf . webmail-netaddress-article)
119 "http://www.netaddress.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1"
120 webmail-session id))))
122 (defvar webmail-variables
123 '(address article-snarf article-url list-snarf list-url
124 login-url login-snarf open-url open-snarf site articles
125 post-process paranoid trash-url))
127 (defconst webmail-version "webmail 1.0")
129 (defvar webmail-newmail-only nil
130 "Only fetch new mails.")
132 (defvar webmail-move-to-trash-can t
133 "Move mail to trash can after fetch it.")
135 ;;; Internal variables
137 (defvar webmail-address nil)
138 (defvar webmail-paranoid nil)
139 (defvar webmail-aux nil)
140 (defvar webmail-session nil)
141 (defvar webmail-article-snarf nil)
142 (defvar webmail-article-url nil)
143 (defvar webmail-list-snarf nil)
144 (defvar webmail-list-url nil)
145 (defvar webmail-login-url nil)
146 (defvar webmail-login-snarf nil)
147 (defvar webmail-open-snarf nil)
148 (defvar webmail-open-url nil)
149 (defvar webmail-trash-url nil)
150 (defvar webmail-articles nil)
151 (defvar webmail-post-process nil)
153 (defvar webmail-buffer nil)
154 (defvar webmail-buffer-list nil)
155 ;;; Interface functions
157 (defun webmail-setdefault (type)
158 (let ((type-def (cdr (assq type webmail-type-definition)))
159 (vars webmail-variables)
162 (if (setq pair (assq var type-def))
163 (set (intern (concat "webmail-" (symbol-name var))) (cdr pair))
164 (set (intern (concat "webmail-" (symbol-name var))) nil)))))
166 (defun webmail-encode-www-form-urlencoded (pairs)
167 "Return PAIRS encoded for forms."
171 (concat (w3-form-encode-xwfu (car data)) "="
172 (w3-form-encode-xwfu (cdr data)))))
175 (defun webmail-fetch-simple (url content)
176 (let ((url-request-data content)
177 (url-request-method "POST")
178 (url-request-extra-headers
179 '(("Content-type" . "application/x-www-form-urlencoded"))))
183 (defun webmail-fetch-form (url pairs)
184 (let ((url-request-data (webmail-encode-www-form-urlencoded pairs))
185 (url-request-method "POST")
186 (url-request-extra-headers
187 '(("Content-type" . "application/x-www-form-urlencoded"))))
191 (defun webmail-eval (expr)
194 (cons (webmail-eval (car expr)) (webmail-eval (cdr expr))))
200 (defun webmail-url (xurl)
202 ((eq (car xurl) 'content)
204 (webmail-fetch-simple (if (stringp (car xurl))
206 (apply 'format (webmail-eval (car xurl))))
207 (apply 'format (webmail-eval (cdr xurl)))))
208 ((eq (car xurl) 'post)
210 (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
212 (nnweb-insert (apply 'format (webmail-eval xurl))))))
214 (defun webmail-decode-entities ()
215 (goto-char (point-min))
216 (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t)
217 (replace-match (char-to-string
218 (if (eq (aref (match-string 1) 0) ?\#)
219 (string-to-number (substring (match-string 1) 1))
220 (or (cdr (assq (intern (match-string 1))
225 (defun webmail-decode-entities-string (str)
228 (webmail-decode-entities)
229 (buffer-substring (point-min) (point-max))))
231 (defun webmail-remove-markup ()
232 (goto-char (point-min))
233 (while (search-forward "<!--" nil t)
234 (delete-region (match-beginning 0)
235 (or (search-forward "-->" nil t)
237 (goto-char (point-min))
238 (while (re-search-forward "<[^>]+>" nil t)
239 (replace-match "" t t)))
241 (defun webmail-init ()
242 "Initialize buffers and such."
243 (if (gnus-buffer-live-p webmail-buffer)
244 (set-buffer webmail-buffer)
246 (nnheader-set-temp-buffer " *webmail*"))))
248 (defvar url-package-name)
249 (defvar url-package-version)
250 (defvar url-cookie-multiple-line)
251 (defvar url-confirmation-func)
253 ;; Hack W3 POST redirect. See `url-parse-mime-headers'.
255 ;; Netscape uses "GET" as redirect method when orignal method is POST
256 ;; and status is 302, .i.e no security risks by default without
259 ;; Some web servers (at least Apache used by yahoo) return status 302
260 ;; instead of 303, though they mean 303.
262 (defun webmail-url-confirmation-func (prompt)
264 ((equal prompt (concat "Honor redirection with non-GET method "
265 "(possible security risks)? "))
267 ((equal prompt "Continue (with method of GET)? ")
271 (defun webmail-refresh-redirect ()
272 "Redirect refresh url in META."
273 (goto-char (point-min))
274 (while (re-search-forward "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
276 (let ((url (match-string 1)))
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 (nnweb-insert (cdr item))
320 (if webmail-article-snarf
321 (funcall webmail-article-snarf file id))
322 (when (and webmail-trash-url webmail-move-to-trash-can)
323 (message "Move mail #%d to trash can..." n)
326 (webmail-url webmail-trash-url)
328 (while (setq buf (pop webmail-buffer-list))
332 (while (setq buf (pop webmail-buffer-list))
335 (if webmail-post-process
336 (funcall webmail-post-process))))
340 (defun webmail-hotmail-open ()
341 (goto-char (point-min))
342 (if (re-search-forward
343 "action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t)
344 (setq webmail-aux (match-string 1))
345 (error "Can't find login url (open@1)")))
347 (defun webmail-hotmail-list ()
349 (goto-char (point-min))
350 (if (re-search-forward "[0-9]+ messages, [0-9]+ new")
351 (message "Found %s" (match-string 0)))
352 (goto-char (point-min))
353 (if (re-search-forward
354 "action=\"https?://\\([^/]+\\)/cgi-bin/HoTMaiL" nil t)
355 (setq site (match-string 1))
356 (error "Can't find server url (list@1)"))
357 (goto-char (point-min))
358 (if (re-search-forward "disk=\\([^&]+\\)&" nil t)
360 (concat "http://" site "/cgi-bin/HoTMaiL?disk="
362 (error "Can't find disk (list@2)"))
363 (goto-char (point-max))
364 (while (re-search-backward
365 "newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\""
367 (if (setq url (match-string 1))
369 (if (or newp (not webmail-newmail-only))
371 (if (string-match "msg=\\([^&]+\\)" url)
372 (setq id (match-string 1 url)))
373 (push (cons id (concat "http://" site url))
378 (defun webmail-hotmail-article (file id)
379 (let (p attachment count mime)
381 (goto-char (point-min))
382 (if (not (search-forward "<DIV>" nil t))
383 (error "Can't find start label (article@1)"))
384 (narrow-to-region (point-min) (match-beginning 0))
385 (if (not (search-backward "<table" nil t 2))
386 (error "Can't find start label (article@1.1)"))
387 (delete-region (point-min) (match-beginning 0))
388 (while (search-forward "<a href=" nil t)
389 (setq p (match-beginning 0))
390 (search-forward "</a>" nil t)
391 (delete-region p (match-end 0)))
392 (webmail-remove-markup)
393 (webmail-decode-entities)
394 (goto-char (point-min))
396 (goto-char (point-min))
397 (when (search-forward "\n\n" nil t)
399 (delete-region (point) (point-max)))
400 (goto-char (point-max))
404 (while (re-search-forward "<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\"" nil t)
405 (if (setq attachment (match-string 1))
406 (let ((filename (match-string 2))
407 bufname) ;; Attachment
408 (delete-region p (match-end 0))
410 (set-buffer (generate-new-buffer " *webmail-att*"))
411 (nnweb-insert attachment)
412 (push (current-buffer) webmail-buffer-list)
413 (setq bufname (buffer-name)))
415 (insert "<#part type="
417 (string-match "\\.[^\\.]+$" filename)
418 (mailcap-extension-to-mime
419 (match-string 0 filename)))
420 "application/octet-stream"))
421 (insert " buffer=\"" bufname "\"")
422 (insert " filename=\"" filename "\"")
423 (insert " disposition=\"inline\"")
424 (insert "><#/part>\n")
426 (delete-region p (match-end 0))
428 (while (and (> count 0)
429 (re-search-forward "</div>\\|\\(<div>\\)" nil t))
431 (setq count (1+ count))
432 (if (= (setq count (1- count)) 0)
433 (delete-region (match-beginning 0)
435 (narrow-to-region p (point))
436 (goto-char (point-min))
438 ((looking-at "<pre>")
439 (goto-char (match-end 0))
440 (if (looking-at "$") (forward-char))
441 (delete-region (point-min) (point))
442 (webmail-remove-markup)
443 (webmail-decode-entities)
447 (insert "<#part type=\"text/html\" disposition=inline>")
448 (goto-char (point-max))
449 (insert "<#/part>")))
450 (goto-char (point-max))
453 (delete-region p (point-max))
454 (goto-char (point-min))
455 ;; Some blank line to seperate mails.
456 (insert "\n\nFrom nobody " (current-time-string) "\n")
458 (insert "Message-ID: <" id "@hotmail.com>\n"))
459 (unless (looking-at "$")
460 (search-forward "\n\n" nil t)
462 (narrow-to-region (point) (point-max))
464 (insert "MIME-Version: 1.0\n"
467 (delete-region (point-min) (point-max)))))
468 (goto-char (point-min))
470 (let (case-fold-search)
471 (while (re-search-forward "^From " nil t)
474 (mm-append-to-file (point-min) (point-max) file)))
478 (defun webmail-yahoo-open ()
479 (goto-char (point-min))
480 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
481 (setq webmail-aux (match-string 1))
482 (error "Can't find login url (open@1)")))
484 (defun webmail-yahoo-login ()
485 (goto-char (point-min))
486 (if (re-search-forward "http://[a-zA-Z][0-9]\\.mail\\.yahoo\\.com/" nil t)
487 (setq webmail-aux (match-string 0))
488 (error "Can't find login url (login@1)"))
489 (if (re-search-forward "YY=[0-9]+" nil t)
490 (setq webmail-aux (concat webmail-aux "ym/us/ShowFolder?"
492 (error "Can't find login url (login@2)")))
494 (defun webmail-yahoo-list ()
495 (let (url (newp t) (tofetch 0))
496 (goto-char (point-min))
497 (when (re-search-forward
498 "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
499 ;(setq listed (match-string 1))
500 (message "Found %s mail(s)" (match-string 2)))
501 (if (string-match "http://[^/]+" webmail-aux)
502 (setq webmail-aux (match-string 0 webmail-aux))
503 (error "Can't find server url (list@1)"))
504 (goto-char (point-min))
505 (while (re-search-forward
506 "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/us/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
508 (if (setq url (match-string 1))
510 (when (or newp (not webmail-newmail-only))
511 (push (cons (match-string 2) (concat webmail-aux url "&toc=1"))
513 (setq tofetch (1+ tofetch)))
516 (message "Fetching %d mail(s)" tofetch)))
518 (defun webmail-yahoo-article (file id)
521 (goto-char (point-min))
522 (if (not (search-forward "value=\"Done\"" nil t))
523 (error "Can't find start label (article@1)"))
524 (if (not (search-forward "<table" nil t))
525 (error "Can't find start label (article@2)"))
526 (delete-region (point-min) (match-beginning 0))
527 (if (not (search-forward "</table>" nil t))
528 (error "Can't find start label (article@3)"))
529 (narrow-to-region (point-min) (match-end 0))
530 (while (search-forward "<a href=" nil t)
531 (setq p (match-beginning 0))
532 (search-forward "</a>" nil t)
533 (delete-region p (match-end 0)))
534 (webmail-remove-markup)
535 (webmail-decode-entities)
536 (goto-char (point-min))
538 (goto-char (point-max))
542 (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
543 (setq attachment (match-string 0))
544 (let (bufname ct ctl cd description)
545 (if (not (search-forward "<table" nil t))
546 (error "Can't find start label (article@4)"))
547 (delete-region p (match-beginning 0))
548 (if (not (search-forward "</table>" nil t))
549 (error "Can't find start label (article@5)"))
550 (narrow-to-region p (match-end 0))
551 (webmail-remove-markup)
552 (webmail-decode-entities)
553 (goto-char (point-min))
555 (setq ct (mail-fetch-field "content-type")
556 ctl (ignore-errors (mail-header-parse-content-type ct))
557 ;;cte (mail-fetch-field "content-transfer-encoding")
558 cd (mail-fetch-field "content-disposition")
559 description (mail-fetch-field "content-description")
560 id (mail-fetch-field "content-id"))
561 (delete-region (point-min) (point-max))
564 (set-buffer (generate-new-buffer " *webmail-att*"))
565 (nnweb-insert (concat webmail-aux attachment))
566 (push (current-buffer) webmail-buffer-list)
567 (setq bufname (buffer-name)))
569 (if (and ctl (not (equal (car ctl) "text/")))
570 (insert " type=\"" (car ctl) "\""))
571 (insert " buffer=\"" bufname "\"")
573 (insert " disposition=\"" cd "\""))
575 (insert " description=\"" description "\""))
576 (insert "><#/part>\n")
578 (delete-region p (point-max))
579 (goto-char (point-min))
580 ;; Some blank line to seperate mails.
581 (insert "\n\nFrom nobody " (current-time-string) "\n")
583 (insert "Message-ID: <" id "@yahoo.com>\n"))
584 (unless (looking-at "$")
585 (search-forward "\n\n" nil t)
587 (narrow-to-region (point) (point-max))
588 (insert "MIME-Version: 1.0\n"
591 (delete-region (point-min) (point-max))))
592 (goto-char (point-min))
594 (let (case-fold-search)
595 (while (re-search-forward "^From " nil t)
598 (mm-append-to-file (point-min) (point-max) file)))
602 (defun webmail-netaddress-open ()
603 (goto-char (point-min))
604 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
605 (setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
606 (error "Can't find login url (open@1)")))
608 (defun webmail-netaddress-login ()
609 (webmail-refresh-redirect)
610 (goto-char (point-min))
611 (if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t)
612 (setq webmail-session (match-string 1))
613 (error "Can't find login url (login@1)")))
615 (defun webmail-netaddress-list ()
617 (goto-char (point-min))
618 (when (re-search-forward
619 "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t)
620 (message "Found %s mail(s), %s unread"
621 (match-string 2) (match-string 1)))
622 (goto-char (point-min))
623 (while (re-search-forward
624 "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
625 (if (setq id (match-string 2))
628 (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
629 (car webmail-open-url)
630 webmail-session id)))
631 (if (or (not webmail-newmail-only)
632 (equal (match-string 1) "True"))
633 (push item webmail-articles))))))
635 (defun webmail-netaddress-single-part ()
636 (goto-char (point-min))
638 ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
641 (while (re-search-forward "[\t\040\r\n]+" nil t)
643 (goto-char (point-min))
644 (while (re-search-forward "<br>" nil t)
645 (replace-match "\n"))
646 (webmail-remove-markup)
647 (webmail-decode-entities)
650 (insert "<#part type=\"text/html\" disposition=inline>")
651 (goto-char (point-max))
655 (defun webmail-netaddress-article (file id)
656 (let (p p1 attachment count mime type)
658 (goto-char (point-min))
659 (if (not (search-forward "Trash" nil t))
660 (error "Can't find start label (article@1)"))
661 (if (not (search-forward "<form>" nil t))
662 (error "Can't find start label (article@2)"))
663 (delete-region (point-min) (match-beginning 0))
664 (if (not (search-forward "</form>" nil t))
665 (error "Can't find start label (article@3)"))
666 (narrow-to-region (point-min) (match-end 0))
667 (goto-char (point-min))
668 (while (re-search-forward "[\040\t\r\n]+" nil t)
670 (goto-char (point-min))
671 (while (search-forward "<b>" nil t)
672 (replace-match "\n"))
673 (webmail-remove-markup)
674 (webmail-decode-entities)
675 (goto-char (point-min))
677 (goto-char (point-min))
678 (while (re-search-forward "^\040+\\|\040+$" nil t)
680 (goto-char (point-min))
681 (while (re-search-forward "\040+" nil t)
683 (goto-char (point-max))
687 (unless (search-forward "<!-- Data -->" nil t)
688 (error "Can't find start label (article@4)"))
690 (delete-region p (point))
691 (goto-char (point-max))
692 (unless (re-search-backward
693 "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
694 (error "Can't find end label (article@5)"))
695 (delete-region (point) (point-max))
697 (while (search-forward
698 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
701 (unless (search-forward "</TABLE>" nil t)
702 (error "Can't find end label (article@6)"))
704 (if (search-backward "<IMG " p t)
706 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
707 (error "Can't find tag (article@7)"))
708 (setq attachment (match-string 1))
709 (setq type (match-string 2))
710 (unless (search-forward "</TABLE>" nil t)
711 (error "Can't find end label (article@8)"))
712 (delete-region p (point))
713 (let (bufname) ;; Attachment
715 (set-buffer (generate-new-buffer " *webmail-att*"))
716 (nnweb-insert (concat (car webmail-open-url) attachment))
717 (push (current-buffer) webmail-buffer-list)
718 (setq bufname (buffer-name)))
719 (insert "<#part type=" type)
720 (insert " buffer=\"" bufname "\"")
721 (insert " disposition=\"inline\"")
722 (insert "><#/part>\n")
728 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
732 (webmail-netaddress-single-part)
733 (goto-char (point-max))
737 (narrow-to-region p (point-max))
738 (setq mime (webmail-netaddress-single-part))
740 (goto-char (point-min))
741 ;; Some blank line to seperate mails.
742 (insert "\n\nFrom nobody " (current-time-string) "\n")
744 (insert "Message-ID: <" id "@usa.net>\n"))
745 (unless (looking-at "$")
746 (search-forward "\n\n" nil t)
749 (narrow-to-region (point-min) (point))
750 (goto-char (point-min))
752 (if (looking-at "MIME-Version\\|Content-Type")
753 (delete-region (point)
756 (if (re-search-forward "^[^ \t]" nil t)
757 (goto-char (match-beginning 0))
760 (goto-char (point-max))
762 (narrow-to-region (point) (point-max))
763 (insert "MIME-Version: 1.0\n"
766 (delete-region (point-min) (point-max))))
767 (goto-char (point-min))
769 (let (case-fold-search)
770 (while (re-search-forward "^From " nil t)
773 (mm-append-to-file (point-min) (point-max) file)))
777 ;;; webmail.el ends here