master
t@thintz.com 13 years ago
commit ea1b96f2c8

@ -0,0 +1,15 @@
; author: Thomas Hintz
; email: t@thintz.com
; license: bsd
(
(license "BSD")
(category web)
(needs http-client uri-common intarweb json srfi-1 srfi-18)
(test-depends test srfi-1)
(author "Thomas Hintz")
(synopsis "Provides a simple interface to the SendGrid mailer service."))

@ -0,0 +1,4 @@
(repo git "git://github.com/ThomasHintz/chicken-scheme-{egg-name}.git") ; optional
(uri targz "https://github.com/ThomasHintz/chicken-scheme-{egg-name}/tarball/{egg-release}")
(release "1")

@ -0,0 +1,21 @@
(use http-client uri-common intarweb json srfi-1 srfi-18)
(define api-user (make-parameter ""))
(define api-key (make-parameter ""))
(define (rest-action url method parameters)
(vector->list (with-input-from-request
(make-request method: method uri: (uri-reference url)) parameters json-read)))
(define (send-mail #!key (subject #f) (text #f) (html #f) (from #f) (from-name #f) (to #f) (reply-to #f) (api-user (api-user)) (api-key (api-key)))
(if (and subject (or text html) from from-name to reply-to)
(rest-action "https://sendgrid.com/api/mail.send.json" 'POST
`((api_user . ,api-user)
(api_key . ,api-key)
(subject . ,subject)
(to . ,to)
(replyto . ,reply-to)
,(if html `(html . ,html) `(text . ,text))
(from . ,from)
(fromname . ,from-name)))
(abort "You must specify all keyword parameters!")))

@ -0,0 +1,15 @@
; author: Thomas Hintz
; email: t@thintz.com
; license: bsd
(compile -s -O2 -d1 send-grid.scm -j amazon-s3)
(compile -s send-grid.import.scm -O2 -d0)
(compile -c -O2 -d1 send-grid.scm -unit send-grid -j send-grid)
(install-extension
'send-grid
; Files to install for your extension:
'("send-grid.o" "send-grid.so" "send-grid.import.so")
; Assoc list with properties for your extension:
'((version 1)
(static "send-grid.o"))) ;; for static linking
Loading…
Cancel
Save