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
27 ;; work. `w3' must be 4.0pre46+one-line-cookie patch or standalone
30 ;; Todo: To support more web mail servers.
33 ;; 1. Net@ddress may corrupt `X-Face'.
36 ;; Webmail is an experimental function, which means NO WARRANTY.
40 (eval-when-compile (require 'cl))
56 ;; Report failure to find w3 at load time if appropriate.
66 (defvar webmail-type-definition
68 ;; Hotmail hate other HTTP user agents and use one line cookie
69 (paranoid agent cookie post)
70 (address . "www.hotmail.com")
71 (open-url "http://www.hotmail.com/")
72 (open-snarf . webmail-hotmail-open)
73 ;; W3 hate redirect POST
75 "http://%s/cgi-bin/dologin?login=%s&passwd=%s&enter=Sign+in&sec=no&curmbox=ACTIVE&_lang=&js=yes&id=2&tw=-10000&beta="
76 webmail-aux user password)
77 (list-snarf . webmail-hotmail-list)
78 (article-snarf . webmail-hotmail-article)
80 "%s&login=%s&f=33792&curmbox=ACTIVE&_lang=&js=&foo=inbox&page=&%s=on&Move+To.x=Move+To&tobox=trAsH"
83 (paranoid cookie post)
84 (address . "mail.yahoo.com")
85 (open-url "http://mail.yahoo.com/")
86 (open-snarf . webmail-yahoo-open)
87 (login-url;; yahoo will not accept GET
90 ".tries=1&.src=ym&.last=&promo=&lg=us&.intl=us&.bypass=&.chkP=Y&.done=http%%253a%%2F%%2Fedit.yahoo.com%%2Fconfig%%2Fmail%%253f.intl%%3D&login=%s&passwd=%s"
92 (login-snarf . webmail-yahoo-login)
93 (list-url "%s&rb=Inbox&YN=1" webmail-aux)
94 (list-snarf . webmail-yahoo-list)
95 (article-snarf . webmail-yahoo-article)
97 "%s/ym/us/ShowFolder?YY=52107&inc=50&order=down&sort=date&pos=0&box=Inbox&DEL=Delete&destBox=&Mid=%s&destBox2="
100 (paranoid cookie post)
101 (address . "www.netaddress.com")
102 (open-url "http://www.netaddress.com/")
103 (open-snarf . webmail-netaddress-open)
104 (login-url;; yahoo will not accept GET
107 "LoginState=2&SuccessfulLogin=%%2Ftpl&NewServerName=www.netaddress.com&JavaScript=JavaScript1.2&DomainID=4&NA31site=classic.netaddress.com&NA31port=80&UserID=%s&passwd=%s"
109 (login-snarf . webmail-netaddress-login)
111 "http://www.netaddress.com/tpl/Mail/%s/List?FolderID=-4&SortUseCase=True"
113 (list-snarf . webmail-netaddress-list)
114 (article-snarf . webmail-netaddress-article)
116 "http://www.netaddress.com/tpl/Message/%s/Move?FolderID=-4&Q=%s&N=&Sort=Date&F=-1"
117 webmail-session id))))
119 (defvar webmail-variables
120 '(address article-snarf article-url list-snarf list-url
121 login-url login-snarf open-url open-snarf site articles
122 post-process paranoid trash-url))
124 (defconst webmail-version "webmail 1.0")
126 (defvar webmail-newmail-only nil
127 "Only fetch new mails.")
129 (defvar webmail-move-to-trash-can t
130 "Move mail to trash can after fetch it.")
132 ;;; Internal variables
134 (defvar webmail-address nil)
135 (defvar webmail-paranoid nil)
136 (defvar webmail-aux nil)
137 (defvar webmail-session nil)
138 (defvar webmail-article-snarf nil)
139 (defvar webmail-article-url nil)
140 (defvar webmail-list-snarf nil)
141 (defvar webmail-list-url nil)
142 (defvar webmail-login-url nil)
143 (defvar webmail-login-snarf nil)
144 (defvar webmail-open-snarf nil)
145 (defvar webmail-open-url nil)
146 (defvar webmail-trash-url nil)
147 (defvar webmail-articles nil)
148 (defvar webmail-post-process nil)
150 (defvar webmail-buffer nil)
151 (defvar webmail-buffer-list nil)
152 ;;; Interface functions
154 (defun webmail-setdefault (type)
155 (let ((type-def (cdr (assq type webmail-type-definition)))
156 (vars webmail-variables)
159 (if (setq pair (assq var type-def))
160 (set (intern (concat "webmail-" (symbol-name var))) (cdr pair))
161 (set (intern (concat "webmail-" (symbol-name var))) nil)))))
163 (defun webmail-encode-www-form-urlencoded (pairs)
164 "Return PAIRS encoded for forms."
168 (concat (w3-form-encode-xwfu (car data)) "="
169 (w3-form-encode-xwfu (cdr data)))))
172 (defun webmail-fetch-simple (url content)
173 (let ((url-request-data content)
174 (url-request-method "POST")
175 (url-request-extra-headers
176 '(("Content-type" . "application/x-www-form-urlencoded"))))
180 (defun webmail-fetch-form (url pairs)
181 (let ((url-request-data (webmail-encode-www-form-urlencoded pairs))
182 (url-request-method "POST")
183 (url-request-extra-headers
184 '(("Content-type" . "application/x-www-form-urlencoded"))))
188 (defun webmail-eval (expr)
191 (cons (webmail-eval (car expr)) (webmail-eval (cdr expr))))
197 (defun webmail-url (xurl)
198 (mm-with-unibyte-current-buffer
200 ((eq (car xurl) 'content)
202 (webmail-fetch-simple (if (stringp (car xurl))
204 (apply 'format (webmail-eval (car xurl))))
205 (apply 'format (webmail-eval (cdr xurl)))))
206 ((eq (car xurl) 'post)
208 (webmail-fetch-form (car xurl) (webmail-eval (cdr xurl))))
210 (nnweb-insert (apply 'format (webmail-eval xurl)))))))
212 (defun webmail-decode-entities ()
213 (goto-char (point-min))
214 (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+\\);" nil t)
215 (replace-match (char-to-string
216 (if (eq (aref (match-string 1) 0) ?\#)
217 (string-to-number (substring (match-string 1) 1))
218 (or (cdr (assq (intern (match-string 1))
223 (defun webmail-decode-entities-string (str)
226 (webmail-decode-entities)
227 (buffer-substring (point-min) (point-max))))
229 (defun webmail-remove-markup ()
230 (goto-char (point-min))
231 (while (search-forward "<!--" nil t)
232 (delete-region (match-beginning 0)
233 (or (search-forward "-->" nil t)
235 (goto-char (point-min))
236 (while (re-search-forward "<[^>]+>" nil t)
237 (replace-match "" t t)))
239 (defun webmail-init ()
240 "Initialize buffers and such."
241 (if (gnus-buffer-live-p webmail-buffer)
242 (set-buffer webmail-buffer)
244 (nnheader-set-temp-buffer " *webmail*"))))
246 (defvar url-package-name)
247 (defvar url-package-version)
248 (defvar url-cookie-multiple-line)
249 (defvar url-confirmation-func)
251 ;; Hack W3 POST redirect. See `url-parse-mime-headers'.
253 ;; Netscape uses "GET" as redirect method when orignal method is POST
254 ;; and status is 302, .i.e no security risks by default without
257 ;; Some web servers (at least Apache used by yahoo) return status 302
258 ;; instead of 303, though they mean 303.
260 (defun webmail-url-confirmation-func (prompt)
262 ((equal prompt (concat "Honor redirection with non-GET method "
263 "(possible security risks)? "))
265 ((equal prompt "Continue (with method of GET)? ")
269 (defun webmail-refresh-redirect ()
270 "Redirect refresh url in META."
271 (goto-char (point-min))
272 (while (re-search-forward "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
274 (let ((url (match-string 1)))
277 (goto-char (point-min))))
279 (defun webmail-fetch (file subtype user password)
281 (webmail-setdefault subtype)
282 (let ((url-package-name (if (memq 'agent webmail-paranoid)
285 (url-package-version (if (memq 'agent webmail-paranoid)
287 url-package-version))
288 (url-cookie-multiple-line (if (memq 'cookie webmail-paranoid)
290 url-cookie-multiple-line))
291 (url-confirmation-func (if (memq 'post webmail-paranoid)
292 'webmail-url-confirmation-func
293 url-confirmation-func))
294 url-cookie-storage url-cookie-secure-storage
295 url-cookie-confirmation
298 (setq webmail-articles nil)
299 (when webmail-open-url
301 (webmail-url webmail-open-url))
302 (if webmail-open-snarf (funcall webmail-open-snarf))
303 (when webmail-login-url
305 (webmail-url webmail-login-url))
306 (if webmail-login-snarf
307 (funcall webmail-login-snarf))
308 (when webmail-list-url
310 (webmail-url webmail-list-url))
311 (if webmail-list-snarf
312 (funcall webmail-list-snarf))
313 (while (setq item (pop webmail-articles))
314 (message "Fetching mail #%d..." (setq n (1+ n)))
316 (nnweb-insert (cdr item))
318 (if webmail-article-snarf
319 (funcall webmail-article-snarf file id))
320 (when (and webmail-trash-url webmail-move-to-trash-can)
321 (message "Move mail #%d to trash can..." n)
324 (webmail-url webmail-trash-url)
326 (while (setq buf (pop webmail-buffer-list))
330 (while (setq buf (pop webmail-buffer-list))
333 (if webmail-post-process
334 (funcall webmail-post-process))))
338 (defun webmail-hotmail-open ()
339 (goto-char (point-min))
340 (if (re-search-forward
341 "action=\"https?://\\([^/]+\\)/cgi-bin/dologin" nil t)
342 (setq webmail-aux (match-string 1))
343 (error "Can't find login url (open@1)")))
345 (defun webmail-hotmail-list ()
347 (goto-char (point-min))
348 (if (re-search-forward "[0-9]+ messages, [0-9]+ new")
349 (message "Found %s" (match-string 0)))
350 (goto-char (point-min))
351 (if (re-search-forward
352 "action=\"https?://\\([^/]+\\)/cgi-bin/HoTMaiL" nil t)
353 (setq site (match-string 1))
354 (error "Can't find server url (list@1)"))
355 (goto-char (point-min))
356 (if (re-search-forward "disk=\\([^&]+\\)&" nil t)
358 (concat "http://" site "/cgi-bin/HoTMaiL?disk="
360 (error "Can't find disk (list@2)"))
361 (goto-char (point-max))
362 (while (re-search-backward
363 "newmail\\.gif\\|href=\"\\(/cgi-bin/getmsg\\?[^\"]+\\)\""
365 (if (setq url (match-string 1))
367 (if (or newp (not webmail-newmail-only))
369 (if (string-match "msg=\\([^&]+\\)" url)
370 (setq id (match-string 1 url)))
371 (push (cons id (concat "http://" site url))
376 (defun webmail-hotmail-article (file id)
377 (let (p attachment count mime)
379 (goto-char (point-min))
380 (if (not (search-forward "<DIV>" nil t))
381 (error "Can't find start label (article@1)"))
382 (narrow-to-region (point-min) (match-beginning 0))
383 (if (not (search-backward "<table" nil t 2))
384 (error "Can't find start label (article@1.1)"))
385 (delete-region (point-min) (match-beginning 0))
386 (while (search-forward "<a href=" nil t)
387 (setq p (match-beginning 0))
388 (search-forward "</a>" nil t)
389 (delete-region p (match-end 0)))
390 (webmail-remove-markup)
391 (webmail-decode-entities)
392 (goto-char (point-min))
394 (goto-char (point-min))
395 (when (search-forward "\n\n" nil t)
397 (delete-region (point) (point-max)))
398 (goto-char (point-max))
402 (while (re-search-forward "<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\"" nil t)
403 (if (setq attachment (match-string 1))
404 (let ((filename (match-string 2))
405 bufname);; Attachment
406 (delete-region p (match-end 0))
408 (set-buffer (generate-new-buffer " *webmail-att*"))
409 (nnweb-insert attachment)
410 (push (current-buffer) webmail-buffer-list)
411 (setq bufname (buffer-name)))
413 (insert "<#part type="
415 (string-match "\\.[^\\.]+$" filename)
416 (mailcap-extension-to-mime
417 (match-string 0 filename)))
418 "application/octet-stream"))
419 (insert " buffer=\"" bufname "\"")
420 (insert " filename=\"" filename "\"")
421 (insert " disposition=\"inline\"")
422 (insert "><#/part>\n")
424 (delete-region p (match-end 0))
426 (while (and (> count 0)
427 (re-search-forward "</div>\\|\\(<div>\\)" nil t))
429 (setq count (1+ count))
430 (if (= (setq count (1- count)) 0)
431 (delete-region (match-beginning 0)
433 (narrow-to-region p (point))
434 (goto-char (point-min))
436 ((looking-at "<pre>")
437 (goto-char (match-end 0))
438 (if (looking-at "$") (forward-char))
439 (delete-region (point-min) (point))
440 (webmail-remove-markup)
441 (webmail-decode-entities)
445 (insert "<#part type=\"text/html\" disposition=inline>")
446 (goto-char (point-max))
447 (insert "<#/part>")))
448 (goto-char (point-max))
451 (delete-region p (point-max))
452 (goto-char (point-min))
453 ;; Some blank line to seperate mails.
454 (insert "\n\nFrom nobody " (current-time-string) "\n")
456 (insert "Message-ID: <" id "@hotmail.com>\n"))
457 (unless (looking-at "$")
458 (search-forward "\n\n" nil t)
460 (narrow-to-region (point) (point-max))
462 (insert "MIME-Version: 1.0\n"
465 (delete-region (point-min) (point-max)))))
466 (goto-char (point-min))
468 (let (case-fold-search)
469 (while (re-search-forward "^From " nil t)
472 (mm-append-to-file (point-min) (point-max) file)))
476 (defun webmail-yahoo-open ()
477 (goto-char (point-min))
478 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
479 (setq webmail-aux (match-string 1))
480 (error "Can't find login url (open@1)")))
482 (defun webmail-yahoo-login ()
483 (goto-char (point-min))
484 (if (re-search-forward "http://[a-zA-Z][0-9]\\.mail\\.yahoo\\.com/" nil t)
485 (setq webmail-aux (match-string 0))
486 (error "Can't find login url (login@1)"))
487 (if (re-search-forward "YY=[0-9]+" nil t)
488 (setq webmail-aux (concat webmail-aux "ym/us/ShowFolder?"
490 (error "Can't find login url (login@2)")))
492 (defun webmail-yahoo-list ()
493 (let (url (newp t) (tofetch 0))
494 (goto-char (point-min))
495 (when (re-search-forward
496 "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
497 ;;(setq listed (match-string 1))
498 (message "Found %s mail(s)" (match-string 2)))
499 (if (string-match "http://[^/]+" webmail-aux)
500 (setq webmail-aux (match-string 0 webmail-aux))
501 (error "Can't find server url (list@1)"))
502 (goto-char (point-min))
503 (while (re-search-forward
504 "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/us/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
506 (if (setq url (match-string 1))
508 (when (or newp (not webmail-newmail-only))
509 (push (cons (match-string 2) (concat webmail-aux url "&toc=1"))
511 (setq tofetch (1+ tofetch)))
514 (message "Fetching %d mail(s)" tofetch)))
516 (defun webmail-yahoo-article (file id)
519 (goto-char (point-min))
520 (if (not (search-forward "value=\"Done\"" nil t))
521 (error "Can't find start label (article@1)"))
522 (if (not (search-forward "<table" nil t))
523 (error "Can't find start label (article@2)"))
524 (delete-region (point-min) (match-beginning 0))
525 (if (not (search-forward "</table>" nil t))
526 (error "Can't find start label (article@3)"))
527 (narrow-to-region (point-min) (match-end 0))
528 (while (search-forward "<a href=" nil t)
529 (setq p (match-beginning 0))
530 (search-forward "</a>" nil t)
531 (delete-region p (match-end 0)))
532 (webmail-remove-markup)
533 (webmail-decode-entities)
534 (goto-char (point-min))
536 (goto-char (point-max))
540 (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
541 (setq attachment (match-string 0))
542 (let (bufname ct ctl cd description)
543 (if (not (search-forward "<table" nil t))
544 (error "Can't find start label (article@4)"))
545 (delete-region p (match-beginning 0))
546 (if (not (search-forward "</table>" nil t))
547 (error "Can't find start label (article@5)"))
548 (narrow-to-region p (match-end 0))
549 (webmail-remove-markup)
550 (webmail-decode-entities)
551 (goto-char (point-min))
553 (setq ct (mail-fetch-field "content-type")
554 ctl (ignore-errors (mail-header-parse-content-type ct))
555 ;;cte (mail-fetch-field "content-transfer-encoding")
556 cd (mail-fetch-field "content-disposition")
557 description (mail-fetch-field "content-description")
558 id (mail-fetch-field "content-id"))
559 (delete-region (point-min) (point-max))
562 (set-buffer (generate-new-buffer " *webmail-att*"))
563 (nnweb-insert (concat webmail-aux attachment))
564 (push (current-buffer) webmail-buffer-list)
565 (setq bufname (buffer-name)))
567 (if (and ctl (not (equal (car ctl) "text/")))
568 (insert " type=\"" (car ctl) "\""))
569 (insert " buffer=\"" bufname "\"")
571 (insert " disposition=\"" cd "\""))
573 (insert " description=\"" description "\""))
574 (insert "><#/part>\n")
576 (delete-region p (point-max))
577 (goto-char (point-min))
578 ;; Some blank line to seperate mails.
579 (insert "\n\nFrom nobody " (current-time-string) "\n")
581 (insert "Message-ID: <" id "@yahoo.com>\n"))
582 (unless (looking-at "$")
583 (search-forward "\n\n" nil t)
585 (narrow-to-region (point) (point-max))
586 (insert "MIME-Version: 1.0\n"
589 (delete-region (point-min) (point-max))))
590 (goto-char (point-min))
592 (let (case-fold-search)
593 (while (re-search-forward "^From " nil t)
596 (mm-append-to-file (point-min) (point-max) file)))
600 (defun webmail-netaddress-open ()
601 (goto-char (point-min))
602 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
603 (setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
604 (error "Can't find login url (open@1)")))
606 (defun webmail-netaddress-login ()
607 (webmail-refresh-redirect)
608 (goto-char (point-min))
609 (if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t)
610 (setq webmail-session (match-string 1))
611 (error "Can't find login url (login@1)")))
613 (defun webmail-netaddress-list ()
615 (goto-char (point-min))
616 (when (re-search-forward
617 "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t)
618 (message "Found %s mail(s), %s unread"
619 (match-string 2) (match-string 1)))
620 (goto-char (point-min))
621 (while (re-search-forward
622 "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
623 (if (setq id (match-string 2))
626 (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
627 (car webmail-open-url)
628 webmail-session id)))
629 (if (or (not webmail-newmail-only)
630 (equal (match-string 1) "True"))
631 (push item webmail-articles))))))
633 (defun webmail-netaddress-single-part ()
634 (goto-char (point-min))
636 ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
639 (while (re-search-forward "[\t\040\r\n]+" nil t)
641 (goto-char (point-min))
642 (while (re-search-forward "<br>" nil t)
643 (replace-match "\n"))
644 (webmail-remove-markup)
645 (webmail-decode-entities)
648 (insert "<#part type=\"text/html\" disposition=inline>")
649 (goto-char (point-max))
653 (defun webmail-netaddress-article (file id)
654 (let (p p1 attachment count mime type)
656 (goto-char (point-min))
657 (if (not (search-forward "Trash" nil t))
658 (error "Can't find start label (article@1)"))
659 (if (not (search-forward "<form>" nil t))
660 (error "Can't find start label (article@2)"))
661 (delete-region (point-min) (match-beginning 0))
662 (if (not (search-forward "</form>" nil t))
663 (error "Can't find start label (article@3)"))
664 (narrow-to-region (point-min) (match-end 0))
665 (goto-char (point-min))
666 (while (re-search-forward "[\040\t\r\n]+" nil t)
668 (goto-char (point-min))
669 (while (search-forward "<b>" nil t)
670 (replace-match "\n"))
671 (webmail-remove-markup)
672 (webmail-decode-entities)
673 (goto-char (point-min))
675 (goto-char (point-min))
676 (while (re-search-forward "^\040+\\|\040+$" nil t)
678 (goto-char (point-min))
679 (while (re-search-forward "\040+" nil t)
681 (goto-char (point-max))
685 (unless (search-forward "<!-- Data -->" nil t)
686 (error "Can't find start label (article@4)"))
688 (delete-region p (point))
689 (goto-char (point-max))
690 (unless (re-search-backward
691 "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
692 (error "Can't find end label (article@5)"))
693 (delete-region (point) (point-max))
695 (while (search-forward
696 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
699 (unless (search-forward "</TABLE>" nil t)
700 (error "Can't find end label (article@6)"))
702 (if (search-backward "<IMG " p t)
704 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
705 (error "Can't find tag (article@7)"))
706 (setq attachment (match-string 1))
707 (setq type (match-string 2))
708 (unless (search-forward "</TABLE>" nil t)
709 (error "Can't find end label (article@8)"))
710 (delete-region p (point))
711 (let (bufname);; Attachment
713 (set-buffer (generate-new-buffer " *webmail-att*"))
714 (nnweb-insert (concat (car webmail-open-url) attachment))
715 (push (current-buffer) webmail-buffer-list)
716 (setq bufname (buffer-name)))
717 (insert "<#part type=" type)
718 (insert " buffer=\"" bufname "\"")
719 (insert " disposition=\"inline\"")
720 (insert "><#/part>\n")
726 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
730 (webmail-netaddress-single-part)
731 (goto-char (point-max))
735 (narrow-to-region p (point-max))
736 (setq mime (webmail-netaddress-single-part))
738 (goto-char (point-min))
739 ;; Some blank line to seperate mails.
740 (insert "\n\nFrom nobody " (current-time-string) "\n")
742 (insert "Message-ID: <" id "@usa.net>\n"))
743 (unless (looking-at "$")
744 (search-forward "\n\n" nil t)
747 (narrow-to-region (point-min) (point))
748 (goto-char (point-min))
750 (if (looking-at "MIME-Version\\|Content-Type")
751 (delete-region (point)
754 (if (re-search-forward "^[^ \t]" nil t)
755 (goto-char (match-beginning 0))
758 (goto-char (point-max))
760 (narrow-to-region (point) (point-max))
761 (insert "MIME-Version: 1.0\n"
764 (delete-region (point-min) (point-max))))
765 (goto-char (point-min))
767 (let (case-fold-search)
768 (while (re-search-forward "^From " nil t)
771 (mm-append-to-file (point-min) (point-max) file)))
775 ;;; webmail.el ends here