diff options
Diffstat (limited to 'src/email.clj')
| -rw-r--r-- | src/email.clj | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/email.clj b/src/email.clj index 47d05a8..2fd22e1 100644 --- a/src/email.clj +++ b/src/email.clj @@ -1,6 +1,6 @@ (ns email (:import org.antlr.stringtemplate.StringTemplateGroup) - (:require [clojure.contrib.str-utils2 :as str-utils2])) + (:require [clojure.contrib.str-utils2 :as s])) (defn base-mail [& m] (let [mail (apply hash-map m) @@ -34,11 +34,10 @@ (javax.mail.Message$RecipientType/TO) (javax.mail.internet.InternetAddress/parse to))) (.setSubject msg (:subject mail)) - (.setText msg (:text mail)) + (.setContent msg (:text mail) (:mime mail)) (javax.mail.Transport/send msg)))) (def mail-templates (StringTemplateGroup. "dumpfm-mail" "template/mail" )) -;;(.setErrorListener mail-templates StringTemplateGroup/DEFAULT_ERROR_LISTENER) (.setRefreshInterval mail-templates 3) (defn parse-mail-template [temp props] @@ -49,15 +48,22 @@ [(.trim (.replaceFirst s "SUBJECT: " "")) (.trim b)]))) +(defn classify-mimetype [text] + (if (and (re-find #"(?i)<html>" text) + (re-find #"(?i)</html>" text)) + "text/html" + "text/plain")) + (defn dump-mail [to subject text] (base-mail :user "info@dump.fm" - :password "dumprulez7" - :host "smtpout.secureserver.net" - :port 25 - :ssl false - :to to - :subject subject - :text text)) + :password "dumprulez7" + :host "smtpout.secureserver.net" + :port 25 + :ssl false + :to to + :subject subject + :text text + :mime (classify-mimetype text))) (defn send-registration-email ([nick email] (send-registration-email nick email "welcome")) |
