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 "FILE: wc_pnames.asp -->" nil t))
383 (error "Can't find start label (article@1)"))
384 (setq p (match-end 0))
385 (search-backward "<table" nil t)
386 (narrow-to-region (point-min) p)
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-max))
400 (while (re-search-forward "<div>\\|\\(http://[^/]+/cgi-bin/getmsg/\\([^\?]+\\)\?[^\"]*\\)\"" nil t)
401 (if (setq attachment (match-string 1))
402 (let ((filename (match-string 2))
403 bufname) ;; Attachment
404 (delete-region p (match-end 0))
406 (set-buffer (generate-new-buffer " *webmail-att*"))
407 (nnweb-insert attachment)
408 (push (current-buffer) webmail-buffer-list)
409 (setq bufname (buffer-name)))
411 (insert "<#part type="
413 (string-match "\\.[^\\.]+$" filename)
414 (mailcap-extension-to-mime
415 (match-string 0 filename)))
416 "application/octet-stream"))
417 (insert " buffer=\"" bufname "\"")
418 (insert " filename=\"" filename "\"")
419 (insert " disposition=\"inline\"")
420 (insert "><#/part>\n")
422 (delete-region p (match-end 0))
424 (while (and (> count 0)
425 (re-search-forward "</div>\\|\\(<div>\\)" nil t))
427 (setq count (1+ count))
428 (if (= (setq count (1- count)) 0)
429 (delete-region (match-beginning 0)
431 (narrow-to-region p (point))
432 (goto-char (point-min))
434 ((looking-at "<pre>")
435 (goto-char (match-end 0))
436 (if (looking-at "$") (forward-char))
437 (delete-region (point-min) (point))
438 (webmail-remove-markup)
439 (webmail-decode-entities)
443 (insert "<#part type=\"text/html\" disposition=inline>")
444 (goto-char (point-max))
445 (insert "<#/part>")))
446 (goto-char (point-max))
449 (delete-region p (point-max))
450 (goto-char (point-min))
451 ;; Some blank line to seperate mails.
452 (insert "\n\nFrom nobody " (current-time-string) "\n")
454 (insert "Message-ID: <" id "@hotmail.com>\n"))
455 (unless (looking-at "$")
456 (search-forward "\n\n" nil t)
458 (narrow-to-region (point) (point-max))
460 (insert "MIME-Version: 1.0\n"
463 (delete-region (point-min) (point-max)))))
464 (goto-char (point-min))
466 (let (case-fold-search)
467 (while (re-search-forward "^From " nil t)
470 (mm-append-to-file (point-min) (point-max) file)))
474 (defun webmail-yahoo-open ()
475 (goto-char (point-min))
476 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
477 (setq webmail-aux (match-string 1))
478 (error "Can't find login url (open@1)")))
480 (defun webmail-yahoo-login ()
481 (goto-char (point-min))
482 (if (re-search-forward "http://[a-zA-Z][0-9]\\.mail\\.yahoo\\.com/" nil t)
483 (setq webmail-aux (match-string 0))
484 (error "Can't find login url (login@1)"))
485 (if (re-search-forward "YY=[0-9]+" nil t)
486 (setq webmail-aux (concat webmail-aux "ym/us/ShowFolder?"
488 (error "Can't find login url (login@2)")))
490 (defun webmail-yahoo-list ()
491 (let (url (newp t) (tofetch 0))
492 (goto-char (point-min))
493 (when (re-search-forward
494 "showing [0-9]+-\\([0-9]+\\) of \\([0-9]+\\)" nil t)
495 ;(setq listed (match-string 1))
496 (message "Found %s mail(s)" (match-string 2)))
497 (if (string-match "http://[^/]+" webmail-aux)
498 (setq webmail-aux (match-string 0 webmail-aux))
499 (error "Can't find server url (list@1)"))
500 (goto-char (point-min))
501 (while (re-search-forward
502 "bgcolor=\"#eeeeee\"\\|href=\"\\(/ym/us/ShowLetter\\?MsgId=\\([^&]+\\)&[^\"]*\\)\""
504 (if (setq url (match-string 1))
506 (when (or newp (not webmail-newmail-only))
507 (push (cons (match-string 2) (concat webmail-aux url "&toc=1"))
509 (setq tofetch (1+ tofetch)))
512 (message "Fetching %d mail(s)" tofetch)))
514 (defun webmail-yahoo-article (file id)
517 (goto-char (point-min))
518 (if (not (search-forward "value=\"Done\"" nil t))
519 (error "Can't find start label (article@1)"))
520 (if (not (search-forward "<table" nil t))
521 (error "Can't find start label (article@2)"))
522 (delete-region (point-min) (match-beginning 0))
523 (if (not (search-forward "</table>" nil t))
524 (error "Can't find start label (article@3)"))
525 (narrow-to-region (point-min) (match-end 0))
526 (while (search-forward "<a href=" nil t)
527 (setq p (match-beginning 0))
528 (search-forward "</a>" nil t)
529 (delete-region p (match-end 0)))
530 (webmail-remove-markup)
531 (webmail-decode-entities)
532 (goto-char (point-min))
534 (goto-char (point-max))
538 (while (re-search-forward "[^\"]*/ShowLetter/[^\?]+\?[^\"]*" nil t)
539 (setq attachment (match-string 0))
540 (let (bufname ct ctl cd description)
541 (if (not (search-forward "<table" nil t))
542 (error "Can't find start label (article@4)"))
543 (delete-region p (match-beginning 0))
544 (if (not (search-forward "</table>" nil t))
545 (error "Can't find start label (article@5)"))
546 (narrow-to-region p (match-end 0))
547 (webmail-remove-markup)
548 (webmail-decode-entities)
549 (goto-char (point-min))
551 (setq ct (mail-fetch-field "content-type")
552 ctl (ignore-errors (mail-header-parse-content-type ct))
553 ;;cte (mail-fetch-field "content-transfer-encoding")
554 cd (mail-fetch-field "content-disposition")
555 description (mail-fetch-field "content-description")
556 id (mail-fetch-field "content-id"))
557 (delete-region (point-min) (point-max))
560 (set-buffer (generate-new-buffer " *webmail-att*"))
561 (nnweb-insert (concat webmail-aux attachment))
562 (push (current-buffer) webmail-buffer-list)
563 (setq bufname (buffer-name)))
565 (if (and ctl (not (equal (car ctl) "text/")))
566 (insert " type=\"" (car ctl) "\""))
567 (insert " buffer=\"" bufname "\"")
569 (insert " disposition=\"" cd "\""))
571 (insert " description=\"" description "\""))
572 (insert "><#/part>\n")
574 (delete-region p (point-max))
575 (goto-char (point-min))
576 ;; Some blank line to seperate mails.
577 (insert "\n\nFrom nobody " (current-time-string) "\n")
579 (insert "Message-ID: <" id "@yahoo.com>\n"))
580 (unless (looking-at "$")
581 (search-forward "\n\n" nil t)
583 (narrow-to-region (point) (point-max))
584 (insert "MIME-Version: 1.0\n"
587 (delete-region (point-min) (point-max))))
588 (goto-char (point-min))
590 (let (case-fold-search)
591 (while (re-search-forward "^From " nil t)
594 (mm-append-to-file (point-min) (point-max) file)))
598 (defun webmail-netaddress-open ()
599 (goto-char (point-min))
600 (if (re-search-forward "action=\"\\([^\"]+\\)\"" nil t)
601 (setq webmail-aux (concat (car webmail-open-url) (match-string 1)))
602 (error "Can't find login url (open@1)")))
604 (defun webmail-netaddress-login ()
605 (webmail-refresh-redirect)
606 (goto-char (point-min))
607 (if (re-search-forward "tpl/[^/]+/\\([^/]+\\)" nil t)
608 (setq webmail-session (match-string 1))
609 (error "Can't find login url (login@1)")))
611 (defun webmail-netaddress-list ()
613 (goto-char (point-min))
614 (when (re-search-forward
615 "(\\([0-9]+\\) unread, \\([0-9]+\\) total)" nil t)
616 (message "Found %s mail(s), %s unread"
617 (match-string 2) (match-string 1)))
618 (goto-char (point-min))
619 (while (re-search-forward
620 "MR\\[i\\]\\.R='\\([^']*\\)'\\|MR\\[i\\]\\.Q='\\([^']+\\)'" nil t)
621 (if (setq id (match-string 2))
624 (format "%s/tpl/Message/%s/Read?Q=%s&FolderID=-4&SortUseCase=True&Sort=Date&Headers=True"
625 (car webmail-open-url)
626 webmail-session id)))
627 (if (or (not webmail-newmail-only)
628 (equal (match-string 1) "True"))
629 (push item webmail-articles))))))
631 (defun webmail-netaddress-single-part ()
632 (goto-char (point-min))
634 ((looking-at "[\t\040\r\n]*<font face=[^>]+>[\t\040\r\n]*")
637 (while (re-search-forward "[\t\040\r\n]+" nil t)
639 (goto-char (point-min))
640 (while (re-search-forward "<br>" nil t)
641 (replace-match "\n"))
642 (webmail-remove-markup)
643 (webmail-decode-entities)
646 (insert "<#part type=\"text/html\" disposition=inline>")
647 (goto-char (point-max))
651 (defun webmail-netaddress-article (file id)
652 (let (p p1 attachment count mime type)
654 (goto-char (point-min))
655 (if (not (search-forward "Trash" nil t))
656 (error "Can't find start label (article@1)"))
657 (if (not (search-forward "<form>" nil t))
658 (error "Can't find start label (article@2)"))
659 (delete-region (point-min) (match-beginning 0))
660 (if (not (search-forward "</form>" nil t))
661 (error "Can't find start label (article@3)"))
662 (narrow-to-region (point-min) (match-end 0))
663 (goto-char (point-min))
664 (while (re-search-forward "[\040\t\r\n]+" nil t)
666 (goto-char (point-min))
667 (while (search-forward "<b>" nil t)
668 (replace-match "\n"))
669 (webmail-remove-markup)
670 (webmail-decode-entities)
671 (goto-char (point-min))
673 (goto-char (point-min))
674 (while (re-search-forward "^\040+\\|\040+$" nil t)
676 (goto-char (point-min))
677 (while (re-search-forward "\040+" nil t)
679 (goto-char (point-max))
683 (unless (search-forward "<!-- Data -->" nil t)
684 (error "Can't find start label (article@4)"))
686 (delete-region p (point))
687 (goto-char (point-max))
688 (unless (re-search-backward
689 "[\040\t]*<br>[\040\t\r\n]*<br>[\040\t\r\n]*<form" p t)
690 (error "Can't find end label (article@5)"))
691 (delete-region (point) (point-max))
693 (while (search-forward
694 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
697 (unless (search-forward "</TABLE>" nil t)
698 (error "Can't find end label (article@6)"))
700 (if (search-backward "<IMG " p t)
702 (unless (re-search-forward "HREF=\"\\(/tpl/Attachment/[^/]+/\\([^/]+/[^\?]+\\)[^\"]+\\)\"" p1 t)
703 (error "Can't find tag (article@7)"))
704 (setq attachment (match-string 1))
705 (setq type (match-string 2))
706 (unless (search-forward "</TABLE>" nil t)
707 (error "Can't find end label (article@8)"))
708 (delete-region p (point))
709 (let (bufname) ;; Attachment
711 (set-buffer (generate-new-buffer " *webmail-att*"))
712 (nnweb-insert (concat (car webmail-open-url) attachment))
713 (push (current-buffer) webmail-buffer-list)
714 (setq bufname (buffer-name)))
715 (insert "<#part type=" type)
716 (insert " buffer=\"" bufname "\"")
717 (insert " disposition=\"inline\"")
718 (insert "><#/part>\n")
724 "<TABLE border=\"0\" WIDTH=\"98%\" cellpadding=0 cellspacing=0>"
728 (webmail-netaddress-single-part)
729 (goto-char (point-max))
733 (narrow-to-region p (point-max))
734 (setq mime (webmail-netaddress-single-part))
736 (goto-char (point-min))
737 ;; Some blank line to seperate mails.
738 (insert "\n\nFrom nobody " (current-time-string) "\n")
740 (insert "Message-ID: <" id "@usa.net>\n"))
741 (unless (looking-at "$")
742 (search-forward "\n\n" nil t)
745 (narrow-to-region (point-min) (point))
746 (goto-char (point-min))
748 (if (looking-at "MIME-Version\\|Content-Type")
749 (delete-region (point)
752 (if (re-search-forward "^[^ \t]" nil t)
753 (goto-char (match-beginning 0))
756 (goto-char (point-max))
758 (narrow-to-region (point) (point-max))
759 (insert "MIME-Version: 1.0\n"
762 (delete-region (point-min) (point-max))))
763 (goto-char (point-min))
765 (let (case-fold-search)
766 (while (re-search-forward "^From " nil t)
769 (mm-append-to-file (point-min) (point-max) file)))
773 ;;; webmail.el ends here