Commit 6e8187cf authored by Jan Idzikowski's avatar Jan Idzikowski
Browse files

Remove implementation dependent sockets code by adding usocket dependency.

parent 3defe1b7
Version 20070628.1
2007-06-28
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
......
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)
......
CL-SMTP is a simple lisp smtp client.
It works in ACL, SBCL, CMUCL, OPENMCL, LISPWORKS and CLISP.
It works in ACL, SBCL, CMUCL, OPENMCL, LISPWORKS, CLISP and ECL.
new with support for send attachments, thanks Brian Sorg for the implementation
with authentication support for PLAIN and LOGIN authentication method
used CL-BASE64 package
used cl-base64 and usocket packages (cl-base64 isn't a requirement on ACL)
See INSTALL for prerequisites and build details.
......
;;; -*- mode: Lisp -*-
;;; This file is part of CL-SMTP, the Lisp SMTP Client
;;; Copyright (C) 2004/2005 Jan Idzikowski
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the Lisp Lesser General Public License
;;; (http://opensource.franz.com/preamble.html), known as the LLGPL.
;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; Lisp Lesser GNU General Public License for more details.
;;; File: acl.lisp
;;; Description: Allegro CL Socket Interface
(in-package :cl-smtp)
(defun make-smtp-socket (host port)
(handler-case
(acl-socket:make-socket :remote-host host :remote-port port)
(serious-condition (e)
(error "could not create client socket:~A" e))))
(defun socket-stream (socket)
socket)
(defun get-host-name ()
(excl.osi:gethostname))
......@@ -20,32 +20,16 @@
(:use :cl :asdf)
(:export :send-email))
#+sbcl (require :sb-bsd-sockets)
(in-package :cl-smtp)
(defparameter *debug* nil)
(in-package :cl-smtp)
(defmacro print-debug (str)
`(when *debug*
(print ,str)))
(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"))))
:version "20070904.1"
:depends-on (:usocket #-allegro :cl-base64)
:components ((:file "cl-smtp" :depends-on ("attachments"))
(:file "attachments")))
......@@ -18,15 +18,10 @@
(in-package :cl-smtp)
(defparameter *debug* nil)
(defparameter *x-mailer* (format nil "(~A ~A)"
(lisp-implementation-type)
(lisp-implementation-version)))
(defmacro print-debug (str)
`(when *debug*
(print ,str)))
(defun check-arg (arg name)
(cond
((or (stringp arg)
......@@ -83,7 +78,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 +148,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 +184,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)
......@@ -201,8 +196,7 @@
(write-to-smtp sock (format nil "RCPT TO:<~A>" to))
(multiple-value-bind (code msgstr)
(read-from-smtp sock)
(when (/= code 250)
(when (/= code 250)
(error "in RCPT TO command: ~A" msgstr)))))
......
;;; -*- mode: Lisp -*-
;;; This file is part of CL-SMTP, the Lisp SMTP Client
;;; Copyright (C) 2004/2005 Jan Idzikowski
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the Lisp Lesser General Public License
;;; (http://opensource.franz.com/preamble.html), known as the LLGPL.
;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; Lisp Lesser GNU General Public License for more details.
;;; File: clisp.lisp
;;; Description: Clisp Socket Interface
(in-package :cl-smtp)
(defun make-smtp-socket (host port)
(handler-case
(socket:socket-connect port host :element-type 'character
:external-format
(ext:make-encoding :charset charset:utf-8
:line-terminator :unix))
(serious-condition (e)
(error "could not create client socket:~A" e))))
(defun socket-stream (socket)
socket)
(defun get-host-name ()
#+linux(linux:gethostname 256)
#-linux(let ((str (machine-instance)))
(if (position #\Space str)
(subseq str 0 (position #\Space str))
str)))
;;; -*- mode: Lisp -*-
;;; This file is part of CL-SMTP, the Lisp SMTP Client
;;; Copyright (C) 2004/2005 Jan Idzikowski
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the Lisp Lesser General Public License
;;; (http://opensource.franz.com/preamble.html), known as the LLGPL.
;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; Lisp Lesser GNU General Public License for more details.
;;; File: cmucl.lisp
;;; Description: CmuCL Socket Interface
(in-package :cl-smtp)
(defun make-smtp-socket (host port)
(handler-case
(ext:connect-to-inet-socket host port)
(serious-condition (e)
(error "could not create client socket:~A" e))))
(defun socket-stream (socket)
(system:make-fd-stream
socket
:input t
:output t
:buffering :none))
(defun get-host-name ()
(unix:unix-gethostname))
;;; -*- mode: Lisp -*-
;;; This file is part of CL-SMTP, the Lisp SMTP Client
;;; Copyright (C) 2004/2005 Jan Idzikowski
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the Lisp Lesser General Public License
;;; (http://opensource.franz.com/preamble.html), known as the LLGPL.
;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; Lisp Lesser GNU General Public License for more details.
;;; File: lispworks.lisp
;;; Description: Lispworks Socket Interface
(in-package :cl-smtp)
(eval-when (:compile-toplevel :load-toplevel :execute)
(require "comm"))
(defun make-smtp-socket (host port)
(comm:open-tcp-stream host port))
(defun socket-stream (socket)
socket)
(defun get-host-name ()
(machine-instance))
;;; -*- mode: Lisp -*-
;;; This file is part of CL-SMTP, the Lisp SMTP Client
;;; Copyright (C) 2004/2005 Jan Idzikowski
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the Lisp Lesser General Public License
;;; (http://opensource.franz.com/preamble.html), known as the LLGPL.
;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; Lisp Lesser GNU General Public License for more details.
;;; File: openmcl.lisp
;;; Description: OpenMCL Socket Interface
(in-package :cl-smtp)
(defun make-smtp-socket (host port)
(handler-case
(ccl:make-socket :remote-host host :remote-port port)
(serious-condition (e)
(error "could not create client socket:~A" e))))
(defun socket-stream (socket)
socket)
(defun get-host-name ()
(machine-instance))
;;; -*- mode: Lisp -*-
;;; This file is part of CL-SMTP, the Lisp SMTP Client
;;; Copyright (C) 2004/2005 Jan Idzikowski
;;; This library is free software; you can redistribute it and/or
;;; modify it under the terms of the Lisp Lesser GNU General Public License
;;; (http://opensource.franz.com/preamble.html), known as the LLGPL.
;;; This library is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; Lisp Lesser GNU General Public License for more details.
;;; File: sbcl.lisp
;;; Description: SBCL Socket Interface
(in-package :cl-smtp)
(defun make-smtp-socket (host port)
(handler-case
(let* ((protocol (sb-bsd-sockets:get-protocol-by-name "tcp"))
(socket (make-instance 'sb-bsd-sockets:inet-socket
:type :stream
:protocol protocol)))
(sb-bsd-sockets:socket-connect
socket
(sb-bsd-sockets:host-ent-address
(sb-bsd-sockets:get-host-by-name host))
port)
socket)
(serious-condition (e)
(error "could not create client socket:~A" e))))
(defun socket-stream (socket)
(sb-bsd-sockets:socket-make-stream
socket
:input t
:output t))
(defun get-host-name ()
(sb-unix:unix-gethostname))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment