From ffe3dd504275b89071a27de0d22a9434dedeb9b0 Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Wed, 16 Jan 2008 23:28:20 +0100 Subject: [PATCH] Updated NET.SMTP-CLIENT to work with latest NET.SOCKETS Signed-off-by: Stelian Ionescu --- net.smtp-client.asd | 16 +----- protocols/smtp/client-authentication.lisp | 42 ++++++++-------- protocols/smtp/client-commands.lisp | 44 ++++++++-------- protocols/smtp/client-net.lisp | 84 ++++++++++++++++--------------- protocols/smtp/pkgdcl.lisp | 54 ++++++++++---------- protocols/smtp/smtp.lisp | 4 +- 6 files changed, 120 insertions(+), 124 deletions(-) rewrite protocols/smtp/client-net.lisp (63%) rewrite protocols/smtp/pkgdcl.lisp (91%) diff --git a/net.smtp-client.asd b/net.smtp-client.asd index cc8d76f..7c82b60 100644 --- a/net.smtp-client.asd +++ b/net.smtp-client.asd @@ -1,25 +1,13 @@ -;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*- +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Indent-tabs-mode: NIL -*- (in-package :common-lisp-user) -(eval-when (:compile-toplevel :load-toplevel :execute) - (asdf:operate 'asdf:load-op :asdf-additions)) - -(defpackage #:net.smtp-client.system - (:use #:common-lisp #:asdf-additions)) - -(in-package #:net.smtp-client.system) - (asdf:defsystem :net.smtp-client :description "SMTP client library." :author "Jan Idzikowski" :maintainer "Stelian Ionescu " :licence "LLGPL-2.1" - :depends-on (:iolib-posix - :iolib-utils-symbols - :net.sockets - :cl-base64) - :default-component-class muffled-source-file + :depends-on (:alexandria :osicat :net.sockets :cl-base64) :pathname (merge-pathnames (make-pathname :directory '(:relative "protocols" "smtp")) *load-truename*) :serial t diff --git a/protocols/smtp/client-authentication.lisp b/protocols/smtp/client-authentication.lisp index 49b8f2f..c7b9bc3 100644 --- a/protocols/smtp/client-authentication.lisp +++ b/protocols/smtp/client-authentication.lisp @@ -1,23 +1,25 @@ -;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*- - -;; Copyright (C) 2007 Stelian Ionescu -;; -;; This code is free software; you can redistribute it and/or -;; modify it under the terms of the version 2.1 of -;; the GNU Lesser General Public License as published by -;; the Free Software Foundation, as clarified by the -;; preamble found here: -;; http://opensource.franz.com/preamble.html -;; -;; This program 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 -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU Lesser General -;; Public License along with this library; if not, write to the -;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -;; Boston, MA 02110-1301, USA +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Indent-tabs-mode: NIL -*- +;;; +;;; client-authentication.lisp --- SMTP authentication. +;;; +;;; Copyright (C) 2007-2008, Stelian Ionescu +;;; +;;; This code is free software; you can redistribute it and/or +;;; modify it under the terms of the version 2.1 of +;;; the GNU Lesser General Public License as published by +;;; the Free Software Foundation, as clarified by the +;;; preamble found here: +;;; http://opensource.franz.com/preamble.html +;;; +;;; This program 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 +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General +;;; Public License along with this library; if not, write to the +;;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +;;; Boston, MA 02110-1301, USA (in-package :net.smtp-client) diff --git a/protocols/smtp/client-commands.lisp b/protocols/smtp/client-commands.lisp index 0b9ab5b..c19c051 100644 --- a/protocols/smtp/client-commands.lisp +++ b/protocols/smtp/client-commands.lisp @@ -1,23 +1,25 @@ -;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*- - -;; Copyright (C) 2007 Stelian Ionescu -;; -;; This code is free software; you can redistribute it and/or -;; modify it under the terms of the version 2.1 of -;; the GNU Lesser General Public License as published by -;; the Free Software Foundation, as clarified by the -;; preamble found here: -;; http://opensource.franz.com/preamble.html -;; -;; This program 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 -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU Lesser General -;; Public License along with this library; if not, write to the -;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -;; Boston, MA 02110-1301, USA +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Indent-tabs-mode: NIL -*- +;;; +;;; client-commands.lisp --- SMTP commands. +;;; +;;; Copyright (C) 2007-2008, Stelian Ionescu +;;; +;;; This code is free software; you can redistribute it and/or +;;; modify it under the terms of the version 2.1 of +;;; the GNU Lesser General Public License as published by +;;; the Free Software Foundation, as clarified by the +;;; preamble found here: +;;; http://opensource.franz.com/preamble.html +;;; +;;; This program 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 +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General +;;; Public License along with this library; if not, write to the +;;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +;;; Boston, MA 02110-1301, USA (in-package :net.smtp-client) @@ -25,7 +27,7 @@ (defvar *smtp-client-commands* (make-hash-table :test #'eq)) (defun make-smtp-cmd-name (name) - (concat-symbol 'smtp- name '-cmd))) + (format-symbol t "~A-~A-~A" '#:smtp name '#:cmd))) (defun read-smtp-return-code (sock expected-code error-msg) (multiple-value-bind (code msg) diff --git a/protocols/smtp/client-net.lisp b/protocols/smtp/client-net.lisp dissimilarity index 63% index c8b122d..56e3cf6 100644 --- a/protocols/smtp/client-net.lisp +++ b/protocols/smtp/client-net.lisp @@ -1,41 +1,43 @@ -;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*- - -;; Copyright (C) 2007 Stelian Ionescu -;; -;; This code is free software; you can redistribute it and/or -;; modify it under the terms of the version 2.1 of -;; the GNU Lesser General Public License as published by -;; the Free Software Foundation, as clarified by the -;; preamble found here: -;; http://opensource.franz.com/preamble.html -;; -;; This program 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 -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU Lesser General -;; Public License along with this library; if not, write to the -;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -;; Boston, MA 02110-1301, USA - -(in-package :net.smtp-client) - -(defun make-smtp-socket (host port) - (make-socket :address-family :internet :type :stream :connect :active - :remote-host host :remote-port port - :external-format '(:iso-8859-1 :line-terminator :dos))) - -(defun write-to-smtp (socket command) - (write-line command socket) - (finish-output socket)) - -(defun format-socket (socket cmdstr &rest args) - (write-to-smtp socket (apply #'format nil cmdstr args))) - -(defun read-from-smtp (sock) - (let* ((line (read-line sock)) - (response-code (parse-integer line :start 0 :junk-allowed t))) - (if (= (char-code (elt line 3)) (char-code #\-)) - (read-from-smtp sock) - (values response-code line)))) +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Indent-tabs-mode: NIL -*- +;;; +;;; client-net.lisp --- Miscellaneous socket routines. +;;; +;;; Copyright (C) 2007-2008, Stelian Ionescu +;;; +;;; This code is free software; you can redistribute it and/or +;;; modify it under the terms of the version 2.1 of +;;; the GNU Lesser General Public License as published by +;;; the Free Software Foundation, as clarified by the +;;; preamble found here: +;;; http://opensource.franz.com/preamble.html +;;; +;;; This program 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 +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General +;;; Public License along with this library; if not, write to the +;;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +;;; Boston, MA 02110-1301, USA + +(in-package :net.smtp-client) + +(defun make-smtp-socket (host port) + (make-socket :family :internet :type :stream :connect :active + :remote-host host :remote-port port + :external-format '(:iso-8859-1 :eol-style :crlf))) + +(defun write-to-smtp (socket command) + (write-line command socket) + (finish-output socket)) + +(defun format-socket (socket cmdstr &rest args) + (write-to-smtp socket (apply #'format nil cmdstr args))) + +(defun read-from-smtp (sock) + (let* ((line (read-line sock)) + (response-code (parse-integer line :start 0 :junk-allowed t))) + (if (= (char-code (elt line 3)) (char-code #\-)) + (read-from-smtp sock) + (values response-code line)))) diff --git a/protocols/smtp/pkgdcl.lisp b/protocols/smtp/pkgdcl.lisp dissimilarity index 91% index 6610cd8..91c22be 100644 --- a/protocols/smtp/pkgdcl.lisp +++ b/protocols/smtp/pkgdcl.lisp @@ -1,26 +1,28 @@ -;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*- - -;; Copyright (C) 2007 Stelian Ionescu -;; -;; This code is free software; you can redistribute it and/or -;; modify it under the terms of the version 2.1 of -;; the GNU Lesser General Public License as published by -;; the Free Software Foundation, as clarified by the -;; preamble found here: -;; http://opensource.franz.com/preamble.html -;; -;; This program 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 -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU Lesser General -;; Public License along with this library; if not, write to the -;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, -;; Boston, MA 02110-1301, USA - -(in-package :common-lisp-user) - -(defpackage :net.smtp-client - (:use #:common-lisp #:iolib-utils #:net.sockets #:cl-base64) - (:export #:send-email)) +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Indent-tabs-mode: NIL -*- +;;; +;;; pkgdcl.lisp --- Package definition. +;;; +;;; Copyright (C) 2007-2008, Stelian Ionescu +;;; +;;; This code is free software; you can redistribute it and/or +;;; modify it under the terms of the version 2.1 of +;;; the GNU Lesser General Public License as published by +;;; the Free Software Foundation, as clarified by the +;;; preamble found here: +;;; http://opensource.franz.com/preamble.html +;;; +;;; This program 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 +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU Lesser General +;;; Public License along with this library; if not, write to the +;;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +;;; Boston, MA 02110-1301, USA + +(in-package :common-lisp-user) + +(defpackage :net.smtp-client + (:use #:common-lisp :alexandria :net.sockets :cl-base64) + (:export #:send-email)) diff --git a/protocols/smtp/smtp.lisp b/protocols/smtp/smtp.lisp index 5aa9bde..227cbb1 100644 --- a/protocols/smtp/smtp.lisp +++ b/protocols/smtp/smtp.lisp @@ -89,10 +89,10 @@ (read-smtp-return-code sock 220 "Wrong response from smtp server") (cond (authentication - (invoke-smtp-command :ehlo sock (et:get-host-name)) + (invoke-smtp-command :ehlo sock (nix:gethostname)) (invoke-authentication (first authentication) (rest authentication))) (t - (invoke-smtp-command :helo sock (et:get-host-name))))) + (invoke-smtp-command :helo sock (nix:gethostname))))) (defun send-message-envelope (sock from to cc bcc) (invoke-smtp-command :mail-from sock from) -- 2.11.4.GIT