             [postal.core :as postal]
             [clojure.xml :as xml]
             [clojure.zip :as zip]
-            [clojure.java.io :as io :refer (resource)])
-  (:import [java.io ByteArrayInputStream]))
+            [clojure.java.io :as io :refer (resource as-file)])
+  (:import [java.io ByteArrayInputStream FileInputStream BufferedInputStream File]
+           [java.nio.file Files]
+           [java.net URLConnection]))
 (refer-logging)
 
 

          (if (= :img (:tag node))
            (let [cid (str (gensym "img-"))
                  src (-> node :attrs :src)
                  content (or (get src-map src) (resource (str src-root src)))]
              (recur (zip/next (zip/edit loc assoc-in [:attrs :src] (str "cid:" cid)))
                     (cond-> contents
                             content (conj {:type :inline, :content content, :content-id cid}))))
            (recur (zip/next loc) contents)))))))



        (Postal. logger config)))))


(defn- file-content-type
  [^File file]
  (with-open [stream (-> file FileInputStream. BufferedInputStream.)]
    (URLConnection/guessContentTypeFromStream stream)))


(defn- make-inline
  [html-str src-root src-map]
  (let [src-root (str src-root (when-not (= (last src-root) \/) "/"))]
