chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] smtp


From: Jean-Philippe Theberge
Subject: [Chicken-users] smtp
Date: Sat, 22 Dec 2007 11:24:46 -0500
User-agent: Icedove 1.5.0.14pre (X11/20071025)

I havent pointed out what is wrong with smtp:open but this "all-in-one" modified version is working:


(define (smtp:message host localhost from to headers body debug)
 (define smtp (smtp:connect host localhost debug))
 (when (smtp-open smtp)
   (smtp-error "SMTP data transfer already in progress" 0) )
 (send smtp "MAIL FROM: <~A>" from)
 (fetch smtp)
 (for-each
  (lambda (tl)
    (send smtp "RCPT TO: <~A>" tl)
    (fetch smtp))
  (if (string? to) `(,to) to))
 (send smtp "DATA")
 (fetch smtp)
 (send smtp (sprintf "~A\r\n\r\n~A\r\n."
(string-join (map (lambda (x) (string-join x ": ")) headers) "\r\n")
           body))
 (fetch smtp)
 (send smtp "QUIT")
 (fetch smtp))

Example use:

(smtp:message "relais.videotron.ca" ; smtp-server
   (get-host-name)                              ; localhost
   "address@hidden"      ; from
   "address@hidden"    ; to
   '(("subject" "this is a test"))          ; extra-headers
   "TESTING!!!"                               ; body
   #t)                                                  ; verbose on

BuddyPilots <http://www.buddypilots.com>
*Jean-Philippe Théberge*
*Programmeur Architecte*
Tel: (514) 353-2307







reply via email to

[Prev in Thread] Current Thread [Next in Thread]