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)
201 (mm-with-unibyte-current-buffer
203 ((eq (car xurl) 'content)
205 (webmail-fetch-simple (if (stringp (car xurl))
207 (apply 'format (webmail-eval (car xurl))))
208 (apply 'format (webmail-eval (cdr xurl)))))
209 ((eq (car xurl) 'post)
211 (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
213 (nnweb-insert (apply 'format (webmail-eval xurl)))))))
215 (defun webmail-decode-entities ()
216 (goto-char (point-min))
217 (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t)
218 (replace-match (char-to-string
219 (if (eq (aref (match-string 1) 0) ?\#)
220 (string-to-number (substring (match-string 1) 1))
221 (or (cdr (assq (intern (match-string 1))
226 (defun webmail-decode-entities-string (str)
229 (webmail-decode-entities)
230 (buffer-substring (point-min) (point-max))))
232 (defun webmail-remove-markup ()
233 (goto-char (point-min))
234 (while (search-forward "<!--" nil t)
235 (delete-region (match-beginning 0)
236 (or (search-forward "-->" nil t)
238 (goto-char (point-min))
239 (while (re-search-forward "<[^>]+>" nil t)
240 (replace-match "" t t)))
242 (defun webmail-init ()
243 "Initialize buffers and such."
244 (if (gnus-buffer-live-p webmail-buffer)
245 (set-buffer webmail-buffer)
247 (nnheader-set-temp-buffer " *webmail*"))))
249 (defvar url-package-name)
250 (defvar url-package-version)
251 (defvar url-cookie-multiple-line)
252 (defvar url-confirmation-func)
254 ;; Hack W3 POST redirect. See `url-parse-mime-headers'.
256 ;; Netscape uses "GET" as redirect method when orignal method is POST
257 ;; and status is 302, .i.e no security risks by default without
260 ;; Some web servers (at least Apache used by yahoo) return status 302
261 ;; instead of 303, though they mean 303.
263 (defun webmail-url-confirmation-func (prompt)
265 ((equal prompt (concat "Honor redirection with non-GET method "
266 "(possible security risks)? "))
268 ((equal prompt "Continue (with method of GET)? ")
272 (defun webmail-refresh-redirect ()
273 "Redirect refresh url in META."
274 (goto-char (point-min))
275 (while (re-search-forward "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
277 (let ((url (match-string 1)))
280 (goto-char (point-min))))
282 (defun webmail-fetch (file subtype user password)
284 (webmail-setdefault subtype)
285 (let ((url-package-name (if (memq 'agent webmail-paranoid)
288 (url-package-version (if (memq 'agent webmail-paranoid)
290 url-package-version))
291 (url-cookie-multiple-line (if (memq 'cookie webmail-paranoid)
293 url-cookie-multiple-line))
294 (url-confirmation-func (if (memq 'post webmail-paranoid)
295 'webmail-url-confirmation-func
296 url-confirmation-func))
297 url-cookie-storage url-cookie-secure-storage
298 url-cookie-confirmation
301 (setq webmail-articles nil)
302 (when webmail-open-url
304 (webmail-url webmail-open-url))
305 (if webmail-open-snarf (funcall webmail-open-snarf))
306 (when webmail-login-url
308 (webmail-url webmail-login-url))
309 (if webmail-login-snarf
310 (funcall webmail-login-snarf))
311 (when webmail-list-url
313 (webmail-url webmail-list-url))
314 (if webmail-list-snarf
315 (funcall webmail-list-snarf))
316 (while (setq item (pop webmail-articles))
317 (message "Fetching mail #%d..." (setq n (1+ n)))
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))))
341 (defun webmail-hotmail-open ()
342 (goto-char (point-min))
343 (if (re-search-forward
344 "action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t)
345 (setq webmail-aux (match-string 1))
346 (error "Can't find login url (open@1)")))
348 (defun webmail-hotmail-list ()
350 (goto-char (point-min))
351 (if (re-search-forward "[0-9]+ messages, [0-9]+ new")
352 (message "Found %s" (match-string 0)))
353 (goto-char (point-min))
354 (if (re-search-forward
355 "action=\"https?://\\([^/]+\\)/cgi-bin/HoTMaiL" nil t)
356 (setq site (match-string 1))
357 (error "Can't find server url (list@1)"))
358 (goto-char (point-min))
359 (if (re-search-forward "disk=\\([^&]+\\)&" nil t)
361 (concat "http://" site "/cgi-bin/HoTMaiL?disk="
363 (error "Can't find disk (list@2)"))
364 (goto-char (point-max))
365 (while (re-search-backward
366 "newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\""
368 (if (setq url (match-string 1))
370 (if (or newp (not webmail-newmail-only))
372 (if (string-match "msg=\\([^&]+\\)" url)
373 (setq id (match-string 1 url)))
374 (push (cons id (concat "http://" site url))
379 (defun webmail-hotmail-article (file id)
380 (let (p attachment count mime)
382 (goto-char (point-min))
383 (if (not (search-forward "<DIV>" nil t))
384 (error "Can't find start label (article@1)"))
385 (narrow-to-region (point-min) (match-beginning 0))
386 (if (not (search-backward "<table" nil t 2))
387 (error "Can't find start label (article@1.1)"))
388 (delete-region (point-min) (match-beginning 0))
389 (while (search-forward "<a href=" nil t)
390 (setq p (match-beginning 0))
391 (search-forward "</a>" nil t)
392 (delete-region p (match-end 0)))
393 (webmail-remove-markup)
394 (webmail-decode-entities)
395 (goto-char (point-min))
397 (goto-char (point-min))
398 (when (search-forward "\n\n" nil t)
400 (delete-region (point) (point-max)))
401 (goto-char (point-max))
405 (while (re-search-forward "<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\"" nil t)
406 (if (setq attachment (match-string 1))
407 (let ((filename (match-string 2))
408 bufname);; Attachment
409 (delete-region p (match-end 0))
411 (set-buffer (generate-new-buffer " *webmail-att*"))
412 (nnweb-insert attachment)
413 (push (current-buffer) webmail-buffer-list)
414 (setq bufname (buffer-name)))
416 (insert "<#part type="
418 (string-match "\\.[^\\.]+$" filename)
419 (mailcap-extension-to-mime
420 (match-string 0 filename)))
421 "application/octet-stream"))
422 (insert " buffer=\"" bufname "\"")
423 (insert " filename=\"" filename "\"")
424 (insert " disposition=\"inline\"")
425 (insert "><#/part>\n")
427 (delete-region p (match-end 0))
429 (while (and (> count 0)
430 (re-search-forward "</div>\\|\\(<div>\\)" nil t))
432 (setq count (1+ count))
433 (if (= (setq count (1- count)) 0)
434 (delete-region (match-beginning 0)
436 (narrow-to-region p (point))
437 (goto-char (point-min))
439 ((looking-at "<pre>")
440 (goto-char (match-end 0))
441 (if (looking-at "$") (forward-char))
442 (delete-region (point-min) (point))
443 (webmail-remove-markup)
444 (webmail-decode-entities)
448 (insert "<#part type=\"text/html\" disposition=inline>")
449 (goto-char (point-max))
450 (insert "<#/part>")))
451 (goto-char (point-max))
454 (delete-region p (point-max))
455 (goto-char (point-min))
456 ;; Some blank line to seperate mails.
457 (insert "\n\nFrom nobody " (current-time-string) "\n")
459 (insert "Message-ID: <" id "@hotmail.com>\n"))
460 (unless (looking-at "$")
461 (search-forward "\n\n" nil t)
463 (narrow-to-region (point) (point-max))
465 (insert "MIME-Version: 1.0\n"
468 (delete-region (point-min) (point-max)))))
469 (goto-char (point-min))
471 (let (case-fold-search)
472 (while (re-search-forward "^From " nil t)
475 (mm-append-to-file (point-min) (point-max) file)))
479 (defun webmail-yahoo-open ()
480 (goto-char (point-min))
481 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
482 (setq webmail-aux (match-string 1))
483 (error "Can't find login url (open@1)")))
485 (defun webmail-yahoo-login ()
486 (goto-char (point-min))
487 (if (re-search-forward "http://[a-zA-Z][0-9]\\.mail\\.yahoo\\.com/" nil t)
488 (setq webmail-aux (match-string 0))
489 (error "Can't find login url (login@1)"))
490 (if (re-search-forward "YY=[0-9]+" nil t)
491 (setq webmail-aux (concat webmail-aux "ym/us/ShowFolder?"
493 (error "Can't find login url (login@2)")))
495 (defun webmail-yahoo-list ()
496 (let (url (newp t) (tofetch 0))
497 (goto-char (point-min))
498 (when (re-search-forward
499 "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
500 ;;(setq listed (match-string 1))
501 (message "Found %s mail(s)" (match-string 2)))
502 (if (string-match "http://[^/]+" webmail-aux)
503 (setq webmail-aux (match-string 0 webmail-aux))
504 (error "Can't find server url (list@1)"))
505 (goto-char (point-min))
506 (while (re-search-forward
507 "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/us/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
509 (if (setq url (match-string 1))
511 (when (or newp (not webmail-newmail-only))
512 (push (cons (match-string 2) (concat webmail-aux url "&toc=1"))
514 (setq tofetch (1+ tofetch)))
517 (message "Fetching %d mail(s)" tofetch)))
519 (defun webmail-yahoo-article (file id)
522 (goto-char (point-min))
523 (if (not (search-forward "value=\"Done\"" nil t))
524 (error "Can't find start label (article@1)"))
525 (if (not (search-forward "<table" nil t))
526 (error "Can't find start label (article@2)"))
527 (delete-region (point-min) (match-beginning 0))
528 (if (not (search-forward "</table>" nil t))
529 (error "Can't find start label (article@3)"))
530 (narrow-to-region (point-min) (match-end 0))
531 (while (search-forward "<a href=" nil t)
532 (setq p (match-beginning 0))
533 (search-forward "</a>" nil t)
534 (delete-region p (match-end 0)))
535 (webmail-remove-markup)
536 (webmail-decode-entities)
537 (goto-char (point-min))
539 (goto-char (point-max))
543 (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
544 (setq attachment (match-string 0))
545 (let (bufname ct ctl cd description)
546 (if (not (search-forward "<table" nil t))
547 (error "Can't find start label (article@4)"))
548 (delete-region p (match-beginning 0))
549 (if (not (search-forward "</table>" nil t))
550 (error "Can't find start label (article@5)"))
551 (narrow-to-region p (match-end 0))
552 (webmail-remove-markup)
553 (webmail-decode-entities)
554 (goto-char (point-min))
556 (setq ct (mail-fetch-field "content-type")
557 ctl (ignore-errors (mail-header-parse-content-type ct))
558 ;;cte (mail-fetch-field "content-transfer-encoding")
559 cd (mail-fetch-field "content-disposition")
560 description (mail-fetch-field "content-description")
561 id (mail-fetch-field "content-id"))
562 (delete-region (point-min) (point-max))
565 (set-buffer (generate-new-buffer " *webmail-att*"))
566 (nnweb-insert (concat webmail-aux attachment))
567 (push (current-buffer) webmail-buffer-list)
568 (setq bufname (buffer-name)))
570 (if (and ctl (not (equal (car ctl) "text/")))
571 (insert " type=\"" (car ctl) "\""))
572 (insert " buffer=\"" bufname "\"")
574 (insert " disposition=\"" cd "\""))
576 (insert " description=\"" description "\""))
577 (insert "><#/part>\n")
579 (delete-region p (point-max))
580 (goto-char (point-min))
581 ;; Some blank line to seperate mails.
582 (insert "\n\nFrom nobody " (current-time-string) "\n")
584 (insert "Message-ID: <" id "@yahoo.com>\n"))
585 (unless (looking-at "$")
586 (search-forward "\n\n" nil t)
588 (narrow-to-region (point) (point-max))
589 (insert "MIME-Version: 1.0\n"
592 (delete-region (point-min) (point-max))))
593 (goto-char (point-min))
595 (let (case-fold-search)
596 (while (re-search-forward "^From " nil t)
599 (mm-append-to-file (point-min) (point-max) file)))
603 (defun webmail-netaddress-open ()
604 (goto-char (point-min))
605 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
606 (setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
607 (error "Can't find login url (open@1)")))
609 (defun webmail-netaddress-login ()
610 (webmail-refresh-redirect)
611 (goto-char (point-min))
612 (if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t)
613 (setq webmail-session (match-string 1))
614 (error "Can't find login url (login@1)")))
616 (defun webmail-netaddress-list ()
618 (goto-char (point-min))
619 (when (re-search-forward
620 "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t)
621 (message "Found %s mail(s), %s unread"
622 (match-string 2) (match-string 1)))
623 (goto-char (point-min))
624 (while (re-search-forward
625 "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
626 (if (setq id (match-string 2))
629 (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
630 (car webmail-open-url)
631 webmail-session id)))
632 (if (or (not webmail-newmail-only)
633 (equal (match-string 1) "True"))
634 (push item webmail-articles))))))
636 (defun webmail-netaddress-single-part ()
637 (goto-char (point-min))
639 ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
642 (while (re-search-forward "[\t\040\r\n]+" nil t)
644 (goto-char (point-min))
645 (while (re-search-forward "<br>" nil t)
646 (replace-match "\n"))
647 (webmail-remove-markup)
648 (webmail-decode-entities)
651 (insert "<#part type=\"text/html\" disposition=inline>")
652 (goto-char (point-max))
656 (defun webmail-netaddress-article (file id)
657 (let (p p1 attachment count mime type)
659 (goto-char (point-min))
660 (if (not (search-forward "Trash" nil t))
661 (error "Can't find start label (article@1)"))
662 (if (not (search-forward "<form>" nil t))
663 (error "Can't find start label (article@2)"))
664 (delete-region (point-min) (match-beginning 0))
665 (if (not (search-forward "</form>" nil t))
666 (error "Can't find start label (article@3)"))
667 (narrow-to-region (point-min) (match-end 0))
668 (goto-char (point-min))
669 (while (re-search-forward "[\040\t\r\n]+" nil t)
671 (goto-char (point-min))
672 (while (search-forward "<b>" nil t)
673 (replace-match "\n"))
674 (webmail-remove-markup)
675 (webmail-decode-entities)
676 (goto-char (point-min))
678 (goto-char (point-min))
679 (while (re-search-forward "^\040+\\|\040+$" nil t)
681 (goto-char (point-min))
682 (while (re-search-forward "\040+" nil t)
684 (goto-char (point-max))
688 (unless (search-forward "<!-- Data -->" nil t)
689 (error "Can't find start label (article@4)"))
691 (delete-region p (point))
692 (goto-char (point-max))
693 (unless (re-search-backward
694 "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
695 (error "Can't find end label (article@5)"))
696 (delete-region (point) (point-max))
698 (while (search-forward
699 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
702 (unless (search-forward "</TABLE>" nil t)
703 (error "Can't find end label (article@6)"))
705 (if (search-backward "<IMG " p t)
707 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
708 (error "Can't find tag (article@7)"))
709 (setq attachment (match-string 1))
710 (setq type (match-string 2))
711 (unless (search-forward "</TABLE>" nil t)
712 (error "Can't find end label (article@8)"))
713 (delete-region p (point))
714 (let (bufname);; Attachment
716 (set-buffer (generate-new-buffer " *webmail-att*"))
717 (nnweb-insert (concat (car webmail-open-url) attachment))
718 (push (current-buffer) webmail-buffer-list)
719 (setq bufname (buffer-name)))
720 (insert "<#part type=" type)
721 (insert " buffer=\"" bufname "\"")
722 (insert " disposition=\"inline\"")
723 (insert "><#/part>\n")
729 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
733 (webmail-netaddress-single-part)
734 (goto-char (point-max))
738 (narrow-to-region p (point-max))
739 (setq mime (webmail-netaddress-single-part))
741 (goto-char (point-min))
742 ;; Some blank line to seperate mails.
743 (insert "\n\nFrom nobody " (current-time-string) "\n")
745 (insert "Message-ID: <" id "@usa.net>\n"))
746 (unless (looking-at "$")
747 (search-forward "\n\n" nil t)
750 (narrow-to-region (point-min) (point))
751 (goto-char (point-min))
753 (if (looking-at "MIME-Version\\|Content-Type")
754 (delete-region (point)
757 (if (re-search-forward "^[^ \t]" nil t)
758 (goto-char (match-beginning 0))
761 (goto-char (point-max))
763 (narrow-to-region (point) (point-max))
764 (insert "MIME-Version: 1.0\n"
767 (delete-region (point-min) (point-max))))
768 (goto-char (point-min))
770 (let (case-fold-search)
771 (while (re-search-forward "^From " nil t)
774 (mm-append-to-file (point-min) (point-max) file)))
778 ;;; webmail.el ends here