;;; -*-Scheme-*-
;;;
-;;; $Id: sendmail.scm,v 1.53 2000/06/09 04:11:33 cph Exp $
+;;; $Id: sendmail.scm,v 1.54 2000/06/12 01:38:12 cph Exp $
;;;
;;; Copyright (c) 1991-2000 Massachusetts Institute of Technology
;;;
(if (string? value)
(list (list key value #f))
'()))))
- (let ((add-unique
- (lambda (key value)
- (add key
- (and (not (list-search-positive headers
- (lambda (header)
- (string-ci=? (car header) key))))
- value)))))
- (append headers
- (add "Reply-to"
- (let ((mail-default-reply-to
- (ref-variable mail-default-reply-to buffer)))
- (if (procedure? mail-default-reply-to)
- (mail-default-reply-to)
- mail-default-reply-to)))
- (add "BCC"
- (and (ref-variable mail-self-blind buffer)
- (mail-from-string buffer)))
- (add "FCC" (ref-variable mail-archive-file-name buffer))
- (add-unique "Organization" (mail-organization-string buffer))
- (add-unique "X-Mailer" (mailer-version-string buffer))))))
+ (append headers
+ (add "Reply-to"
+ (let ((mail-default-reply-to
+ (ref-variable mail-default-reply-to buffer)))
+ (if (procedure? mail-default-reply-to)
+ (mail-default-reply-to)
+ mail-default-reply-to)))
+ (add "BCC"
+ (and (ref-variable mail-self-blind buffer)
+ (mail-from-string buffer)))
+ (add "FCC" (ref-variable mail-archive-file-name buffer)))))
(define (mail-from-string buffer)
(let ((address
(string-append (rfc822:quote-string full-name)
" <" address ">"))
(else address)))))
-
-(define (mail-organization-string buffer)
- (let ((organization (ref-variable mail-organization buffer)))
- (and (not (string-null? organization))
- organization)))
-
-(define (mailer-version-string buffer)
- (and (ref-variable mail-identify-reader buffer)
- (string-append "Edwin [version "
- (get-subsystem-version-string "edwin")
- ", MIT Scheme Release "
- (get-subsystem-version-string "release")
- "]")))
\f
(define-variable mail-setup-hook
"An event distributor invoked immediately after a mail buffer is initialized.
(let ((header-end (copy-message mail-buffer end)))
(if (re-search-forward "^FCC:" start header-end #t)
(mail-do-fcc temp-buffer header-end))
+ (let ((add-field
+ (lambda (name value)
+ (if (and value (not (mail-field-start start header-end name)))
+ (mail-insert-field-value header-end name value)))))
+ (add-field "Organization" (mail-organization-string mail-buffer))
+ (add-field "X-Mailer" (mailer-version-string mail-buffer)))
(process-header start header-end)
(mark-temporary! header-end))
(mark-temporary! end)
(mark-temporary! h-start)
h-end)))
+(define (mail-organization-string buffer)
+ (let ((organization (ref-variable mail-organization buffer)))
+ (and (not (string-null? organization))
+ organization)))
+
+(define (mailer-version-string buffer)
+ (and (ref-variable mail-identify-reader buffer)
+ (string-append "Edwin [version "
+ (get-subsystem-version-string "edwin")
+ ", MIT Scheme Release "
+ (get-subsystem-version-string "release")
+ "]")))
+\f
(define (send-mail-buffer mail-buffer lookup-buffer)
(let ((error-buffer
(and (ref-variable mail-interactive lookup-buffer)
(define regexp:non-us-ascii
(char-set->regexp char-set:non-us-ascii))
\f
-(define (delete-mime-headers! h-start h-end)
- (let loop ((f-start h-start))
- (if (mark< f-start h-end)
- (let ((colon (search-forward ":" f-start (line-end f-start 0))))
- (if (not colon)
- (error "Not a header-field line:" f-start))
- (let ((name (string-trim (extract-string f-start (mark-1+ colon))))
- (f-start*
- (if (re-search-forward "^[^ \t]" colon h-end #f)
- (re-match-start 0)
- h-end)))
- (if (or (string=? "mime-version" name)
- (string-prefix? "content-" name))
- (begin
- (delete-string f-start f-start*)
- (loop f-start))
- (loop f-start*)))))))
-
(define (copy-mime-message-body-with-attachments start end attachments
h-end output-mark)
(let ((boundary (random-mime-boundary-string 32)))
(string-append (symbol->string (car disposition))
(mime-parameters->string (cdr disposition))))
+(define (delete-mime-headers! h-start h-end)
+ (let loop ((f-start h-start))
+ (if (mark< f-start h-end)
+ (let ((colon (search-forward ":" f-start (line-end f-start 0))))
+ (if (not colon)
+ (error "Not a header-field line:" f-start))
+ (let ((name (string-trim (extract-string f-start (mark-1+ colon))))
+ (f-start*
+ (if (re-search-forward "^[^ \t]" colon h-end #f)
+ (re-match-start 0)
+ h-end)))
+ (if (or (string=? "mime-version" name)
+ (string-prefix? "content-" name))
+ (begin
+ (delete-string f-start f-start*)
+ (loop f-start))
+ (loop f-start*)))))))
+
(define (insert-headers headers mark)
(for-each (lambda (nv)
(mail-insert-field-value mark (car nv) (cadr nv)))
;;; -*-Scheme-*-
;;;
-;;; $Id: snr.scm,v 1.57 2000/06/08 17:58:29 cph Exp $
+;;; $Id: snr.scm,v 1.58 2000/06/12 01:38:17 cph Exp $
;;;
;;; Copyright (c) 1995-2000 Massachusetts Institute of Technology
;;;
(let ((buffer
(make-mail-buffer `(("Newsgroups"
,(if group (news-group:name group) ""))
- ("Subject" "")
- ,@(x-newsreader-header
- (current-news-server-buffer #f)))
+ ("Subject" ""))
#f
selector
(if no-erase?
(set-buffer-point! buffer
(mail-position-on-field buffer
"Newsgroups"))))))))
-
-(define (x-newsreader-header buffer)
- `(("X-Newsreader" ,(mailer-version-string buffer))
- ("X-Mailer" #F)))
\f
(define-command news-compose-followup-article
"Begin editing a follow-up to the current News article.
("Distribution"
,(let ((distribution (news-header:field-value header "distribution")))
(and (not (string-null? distribution))
- distribution)))
- ,@(x-newsreader-header buffer))))
+ distribution))))))
\f
(define-major-mode compose-news mail "News"
"Major mode for editing news to be posted on USENET.
(prepare-mail-buffer-for-sending
article-buffer
(news-post-process-headers article-buffer))))
- (if (let* ((start (buffer-start temp-buffer))
- (end (mail-header-end start)))
- (or (mail-field-start start end "To")
+ (let* ((start (buffer-start temp-buffer))
+ (end (mail-header-end start)))
+ (if (or (mail-field-start start end "To")
(mail-field-start start end "CC")
- (mail-field-start start end "BCC")))
- (let ((errors (send-mail-buffer temp-buffer article-buffer)))
- (if errors
- (begin
- (kill-buffer temp-buffer)
- (editor-error errors)))))
+ (mail-field-start start end "BCC"))
+ (let ((errors (send-mail-buffer temp-buffer article-buffer)))
+ (if errors
+ (begin
+ (kill-buffer temp-buffer)
+ (editor-error errors)))))
+ (let ((m (mail-field-start start end "X-Mailer")))
+ (if m
+ (let ((ls (line-start m 0)))
+ (delete-string ls (mark-1+ (char-search-forward #\: ls m)))
+ (insert-string "X-Newsreader" ls)))))
(let ((errors (post-news-buffer temp-buffer article-buffer)))
(kill-buffer temp-buffer)
(if errors (editor-error errors))))))