#| -*-Scheme-*-
-$Id: edwin.pkg,v 1.212 1997/10/22 05:10:46 cph Exp $
+$Id: edwin.pkg,v 1.213 1997/10/31 01:24:24 cph Exp $
Copyright (c) 1989-97 Massachusetts Institute of Technology
(files "sendmail")
(parent (edwin))
(export (edwin)
+ char-set:rfc822-quoted
edwin-command$mail
edwin-command$mail-bcc
edwin-command$mail-cc
edwin-mode$mail
edwin-variable$mail-archive-file-name
edwin-variable$mail-default-reply-to
+ edwin-variable$mail-from-style
edwin-variable$mail-full-name
edwin-variable$mail-header-function
edwin-variable$mail-header-separator
mailer-version-string
make-mail-buffer
prepare-mail-buffer-for-sending
+ rfc822-quote
send-mail-buffer)
(import (runtime system)
known-systems))
;;; -*-Scheme-*-
;;;
-;;; $Id: sendmail.scm,v 1.35 1997/01/03 04:07:00 cph Exp $
+;;; $Id: sendmail.scm,v 1.36 1997/10/31 01:23:02 cph Exp $
;;;
;;; Copyright (c) 1991-97 Massachusetts Institute of Technology
;;;
""
string?)
+(define-variable mail-from-style
+ "Specifies how \"From:\" fields look.
+One of the following values:
+'PARENS king@grassland.com (Elvis Parsley)
+'ANGLES Elvis Parsley <king@grassland.com>
+#F king@grassland.com"
+ 'ANGLES
+ (lambda (object) (memq object '(PARENS ANGLES #F))))
+
(define-variable mail-organization
"The name of your organization.
Appears in the Organization: field of mail and news messages.
"Name of file to write all outgoing messages in, or false for none."
false
string-or-false?)
-
+\f
(define-variable mail-yank-ignored-headers
"Delete these headers from old message when it's inserted in a reply."
(reduce (lambda (x y) (string-append x "\\|" y))
False means let mailer mail back a message to report errors."
false
boolean?)
-\f
+
(define-variable mail-header-separator
"Line used to separate headers from text in messages being composed."
"--text follows this line--"
(add-unique "X-Mailer" (mailer-version-string buffer))))))
(define (mail-from-string buffer)
- (string-append (or (ref-variable user-mail-address buffer)
- (string-append (current-user-name)
- "@"
- (or (ref-variable mail-host-address buffer)
- (os/hostname))))
- (let ((full-name (ref-variable mail-full-name buffer)))
- (if (string-null? full-name)
- ""
- (string-append " (" full-name ")")))))
+ (let ((address
+ (or (ref-variable user-mail-address buffer)
+ (string-append (current-user-name)
+ "@"
+ (or (ref-variable mail-host-address buffer)
+ (os/hostname)))))
+ (full-name (ref-variable mail-full-name buffer)))
+ (if (string-null? full-name)
+ address
+ (case (ref-variable mail-from-style buffer)
+ ((PARENS) (string-append address " (" full-name ")"))
+ ((ANGLES) (string-append (rfc822-quote full-name) " <" address ">"))
+ (else address)))))
+
+(define (rfc822-quote string)
+ (if (string-find-next-char-in-set string char-set:rfc822-quoted)
+ (let loop ((chars (string->list string)) (result (list #\")))
+ (if (null? chars)
+ (list->string (reverse! (cons #\" result)))
+ (loop (cdr chars)
+ (cons (car chars)
+ (if (or (char=? #\\ (car chars))
+ (char=? #\" (car chars)))
+ (cons #\\ result)
+ result)))))
+ string))
+
+(define char-set:rfc822-quoted
+ (char-set-invert
+ (char-set-union char-set:alphanumeric
+ (apply char-set (string->list " !#$%&'*+-/=?^_`{|}~")))))
(define (mail-organization-string buffer)
(let ((organization (ref-variable mail-organization buffer)))