Next: posix mailx, Previous: posix tcp-server-sockets, Up: posix [Index]
sendmail
The library (vicare posix sendmail)
exports a simple API to
send email through the external program sendmail
. This
library is a demonstration of the basic mechanism needed to execute an
external program, write data to its standard input and read data from
its standard output.
The source distribution of Vicare includes a simple demo program demo-sendmail.sps in the tests subdirectory of the source tree.
The executable file sendmail
must be reachable in the current
PATH
; sendmail
is executed with the options:
sendmail -t -i -v
the ASCII text displayed on the standard output is captured for diagnostic.
Send an email message spawning a subprocess that launches
sendmail
. message must be a bytevector representing the
message in ASCII encoding. When successful: return a string
representing the output of sendmail
; otherwise raise an
exception.
The source and destination addresses are extracted from the message itself.
Example:
#!r6rs (import (vicare) (vicare posix sendmail)) (define (send-it message) (define rv (sendmail (string->ascii message))) (display rv) (newline) (flush-output-port (current-output-port))) (send-it "From: <marco@localhost> To: <marco@localhost> Subject: demo 01 MIME-Version: 1.0 Content-Type: text/plain This is demo 01. --\x20; Marco Maggi ")