Next: posix curl, Previous: posix sendmail, Up: posix [Index]
(vicare posix mailx) exports a simple API to send
email through the external program
mailx. 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 and standard error.
The source distribution of Vicare includes a simple demo program demo-mailx.sps in the tests subdirectory of the source tree.
The executable file
mailx must be reachable in the current
mailx is executed with the command line:
MAILRC=/dev/null mailx -t -i -v
the ASCII text displayed on the standard output and standard error is captured for diagnostic.
Send an email message spawning a subprocess that launches
mailx. message must be a bytevector representing the
message in ASCII encoding. When successful: return two strings
representing the output of
mailx to, respectively, standard
output and standard error; otherwise raise an exception.
The source and destination addresses are extracted from the message itself.
#!r6rs (import (vicare) (vicare posix mailx)) (define (send-it message) (define rv (mailx (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 ")