[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mailer strictly from lisp
Date: Tue, 4 Sep 90 12:20:07 EDT
From: kristina@cmi.com (Kristina Fayyad)
System: MacIvory, Genera 8.0
I am trying to use the Mailer strictly from lisp. So far I can
execute the function mailer:mail with to, subject, and message-body
fields,
e.g. (mailer:mail "me@somewhere"
"this is the body of the message"
nil nil nil nil
"this is the subject of the message")
However, this brings up the Mailer (zwei) editor with the message
composed as desired. To send the message it is necessary to press the
End key.
This function is the "Give me a mail editor" function. You probably want
to use ZWEI:SEND-MESSAGE-STRING:
(zwei:send-message-string
(zwei:parse-addresses "me@somewhere")
"This is the body of the message"
:subject "This is the subject of the message")
Be prepared to catch errors, of course. These might have the flavor
ZWEI:BARF mixed in.
[The way I found this function was to use the Zmacs command m-X Edit CP Command,
asking for the source for the CP command "Send Mail", which I knew had the
behaviour you wanted.]
There is, of course, much lower-lying software for sending mail which
doesn't use the Zmail interface. For example, here is a schematic of an
automatic mail-sender I wrote some time back:
(defun send-mail-to (&key recipients subject text
(date (time:get-universal-time))
(message-id (zwei:generate-standard-message-id date)))
(loop named mail-sent
for mail-service in (zwei:find-sorted-mail-services)
do
(condition-case ()
(mailer:with-mailer (mailer mail-service)
(send mailer :start-message `(:user ,si:*user*))
(loop for recipient in (zwei:parse-addresses recipients) do
(send mailer :verify-recipient recipient))
(with-input-from-string
(message-stream (format nil "Date: ~\\TIME\\~%~
~@[Subject: ~A~%~]~
From: ~A~%~
To: ~A~%~
Message-id: ~A~%~
~2%~A"
date subject si:*user*
recipients message-id
text))
(send mailer :receive-message nil message-stream)))
(error)
(:no-error (return-from mail-sent)))))
Now you can say
(send-mail-to :recipients "me@somewhere"
:subject "This is the subject line"
:text "This is the text body")
and it will do the right thing.