[cl-smtp-devel] Re: cl-smtp usocket

Erik Huelsmann ehuels at gmail.com
Sun May 20 20:33:47 UTC 2007


On 5/15/07, idzikowski <jan.idzikowski at gmail.com> wrote:
> Hello Erik,
>
> sorry for no answer to your mail to the cl-smtp-devel list from Apr  7 2007,
> i never got this message.
>
> Your suggestion to use usocket is a good idea,
> send me the patch and put it in the cvs, but i have not all supported
> lisp implementations installed to test ist. I can test it with
> acl/sbcl/cmucl/clisp on linux and some on windows.

Please find attached the patch to move cl-smtp to usocket. Note that
there's no need for any platform specific stuff any more, apart from
the cl-base64 conditionals.

Note that you need Subversion trunk usocket to test this patch. Also,
I added usocket::get-host-name, but I'm not sure I want it to be part
of the exported interface. I'll support the function on all current
and new implementations though.

Also, locally, I removed all sockets-compat-layer files (but the patch
doesn't seem able to convey this):

rm acl.lisp clisp.lisp lispworks.lisp openmcl.lisp sbcl.lisp cmucl.lisp

The remainder of the patch (including updates to CHANGELOG, INSTALL
and README, but without the version increment in cl-smtp.asd):

Index: CHANGELOG
===================================================================
RCS file: /project/cl-smtp/cvsroot/cl-smtp/CHANGELOG,v
retrieving revision 1.5
diff -u -r1.5 CHANGELOG
--- CHANGELOG   4 Apr 2006 13:04:40 -0000       1.5
+++ CHANGELOG   20 May 2007 20:31:07 -0000
@@ -1,3 +1,10 @@
+Version .........1
+2007-??-??
+Remove implementation dependent sockets code by adding usocket dependency.
+Change cl-smtp.asd cl-smtp.lisp README INSTALL
+ (remove acl.lisp clisp.lisp cmucl.lisp sbcl.lisp lispworks.lisp openmcl.lisp)
+
+
 Version 20060404.1
 2006-04-04
 "ADD" support for attachment, thanks Brian Sorg for the implementation
Index: INSTALL
===================================================================
RCS file: /project/cl-smtp/cvsroot/cl-smtp/INSTALL,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 INSTALL
--- INSTALL     1 Nov 2005 18:34:57 -0000       1.1.1.1
+++ INSTALL     20 May 2007 20:31:07 -0000
@@ -1,10 +1,12 @@

-CL-SMTP works in ACL, SBCL, CMUCL, OPENMCL, LISPWORKS and CLISP.
+CL-SMTP works in all implementations supported by its dependencies.

-For SBCL you need sb-bsd-sockets.
+For all implementations you'll need usocket
+and cl-base64 (the latter isn't a requirement on ACL).

 CL-SMTP has a asdf system definition file.
-load this file:
+
+To load this file:

 (asdf:operate 'asdf:load-op 'cl-smtp)

Index: README
===================================================================
RCS file: /project/cl-smtp/cvsroot/cl-smtp/README,v
retrieving revision 1.5
diff -u -r1.5 README
--- README      24 May 2006 10:46:22 -0000      1.5
+++ README      20 May 2007 20:31:07 -0000
@@ -1,10 +1,11 @@

-CL-SMTP is a simple lisp smtp client.
-It works in ACL, SBCL, CMUCL, OPENMCL, LISPWORKS and CLISP.
+CL-SMTP is a simple lisp smtp client.
+It works in all lisp implementations supported by its dependencies.

-new with support for send attachments, thanks Brian Sorg for the
implementation+New with support for send attachments,
+  thanks Brian Sorg for the implementation.

-with authentication support for PLAIN and LOGIN authentication method
+With authentication support for PLAIN and LOGIN authentication method

 used CL-BASE64 package

Index: cl-smtp.asd
===================================================================
RCS file: /project/cl-smtp/cvsroot/cl-smtp/cl-smtp.asd,v
retrieving revision 1.6
diff -u -r1.6 cl-smtp.asd
--- cl-smtp.asd 4 Apr 2006 13:04:40 -0000       1.6
+++ cl-smtp.asd 20 May 2007 20:31:07 -0000
@@ -20,32 +20,13 @@
        (:use :cl :asdf)
        (:export :send-email))

-#+sbcl (require :sb-bsd-sockets)
-
-
 (in-package :cl-smtp)

 (asdf:defsystem :cl-smtp
         :version "20060404.1"
        :depends-on
-               #-allegro (:cl-base64)
-               #+allegro ()
-       :components
-               (#+sbcl(:file "sbcl")
-                #+allegro(:file "acl")
-                 #+cmu(:file "cmucl")
-                 #+clisp(:file "clisp")
-                #+openmcl(:file "openmcl")
-                #+lispworks(:file "lispworks")
-                (:file "cl-smtp" :depends-on #+sbcl("sbcl")
-                                             #+allegro("acl")
-                                              #+cmu("cmucl")
-                                              #+clisp("clisp")
-                                             #+openmcl("openmcl")
-                                             #+lispworks("lispworks"))
-                (:file "attachments" :depends-on #+sbcl("sbcl")
-                                             #+allegro("acl")
-                                              #+cmu("cmucl")
-                                              #+clisp("clisp")
-                                             #+openmcl("openmcl")
-                                             #+lispworks("lispworks"))))
+                (:usocket #-allegro :cl-base64)
+       :components
+               ((:file "cl-smtp"
+                        :depends-on ("attachments"))
+                (:file "attachments")))
Index: cl-smtp.lisp
===================================================================
RCS file: /project/cl-smtp/cvsroot/cl-smtp/cl-smtp.lisp,v
retrieving revision 1.5
diff -u -r1.5 cl-smtp.lisp
--- cl-smtp.lisp        4 Apr 2006 13:04:40 -0000       1.5
+++ cl-smtp.lisp        20 May 2007 20:31:07 -0000
@@ -83,7 +83,7 @@
 (defun send-smtp (host from to subject message
                  &key (port 25) cc bcc reply-to extra-headers
                       display-name authentication attachments buffer-size)
-  (let ((sock (socket-stream (make-smtp-socket host port)))
+  (let ((sock (usocket:socket-stream (usocket:socket-connect host port)))
        (boundary (make-random-boundary)))
     (unwind-protect
        (progn
@@ -153,7 +153,7 @@
       (error "wrong response from smtp server: ~A" msgstr)))
   (cond
    (authentication
-    (write-to-smtp sock (format nil "EHLO ~A" (get-host-name)))
+    (write-to-smtp sock (format nil "EHLO ~A" (usocket::get-host-name)))
     (multiple-value-bind (code msgstr)
         (read-from-smtp sock)
        (when (/= code 250)
@@ -189,7 +189,7 @@
       (error "authentication ~A is not supported in cl-smtp"
             (car authentication)))))
     (t
-     (write-to-smtp sock (format nil "HELO ~A" (get-host-name)))
+     (write-to-smtp sock (format nil "HELO ~A" (usocket::get-host-name)))
      (multiple-value-bind (code msgstr)
         (read-from-smtp sock)
        (when (/= code 250)


Hope this works as well for you as it does for me!

bye,

Erik.



More information about the cl-smtp-devel mailing list