[plt-scheme] send-mail-message

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Tue Jul 12 15:14:57 EDT 2005

On Tue, 12 Jul 2005, Arend P. van der Veen wrote:

> I was hoping the someone can help me.  We have a cgi web app developed
> in plt scheme that uses send-mail-message to send email to users.  It
> works without any problems.  This procedure takes the following
> aurguments:
>
> from-string
> subject-string
> to-list-of-strings
> cc-list-of-strings
> bcc-list-of-string
> body-list-of-strings
>
> [extra-headers-list-of-strings]
>
> We need to specify a seperate reply-to and from strings.  Can
> extra-headers-list-of-strings be used to do this?  If yes, can someone
> show me how to create the header?


Hi Arend,


As far as I can tell, the sendmail package will emit the list of headers
right after the x-mailer header stuff:

;;;;;; in (lib "sendmail.ss" "net")
              (fprintf writer "Subject: ~a~n" subject)
	      (fprintf writer "X-Mailer: MzScheme: see
www.plt-scheme.org~n")
	      (for-each (lambda (s)
			  (display s writer)
			  (newline writer))
			other-headers)
	      (newline writer)
;;;;;;;


Between each header line, it appears to do the necessary "\r\n"  newline
for us.  So it should just be a matter of passing a list of header
strings, like:

    '("Reply-to: nobody at nobody.com"
      "From: santa at clause.com")

and let send-mail-message handle the special newlines for us.


The functions in the (lib "head.ss" "net") subpackage may also help:

######
> (require (lib "head.ss" "net"))
> (insert-field "foo" "bar" empty-header)
"foo: bar\r\n\r\n"
######

although because there are those extra newlines in there, which will cause
some havok unless we're careful.  i.e, passing a list like this:

    (list (insert-field "Reply-to" "nobody at nobody.com" empty-header)
          (insert-field "From" "santa at clause.com" empty-header))

as the extra-headers-list-of-strings will probably do the wrong thing.


Best of wishes!



Posted on the users mailing list.