3 Commits
1 ... master

Author SHA1 Message Date
6ea2abba7d Adding support for file attachments. 2015-08-04 15:51:05 -07:00
70acb4f60f increment version number 2012-01-14 19:33:20 -08:00
289c8cd154 removed test depends 2012-01-14 19:31:56 -08:00
4 changed files with 18 additions and 8 deletions

View File

@@ -9,7 +9,5 @@
(needs http-client uri-common intarweb json srfi-1 srfi-18) (needs http-client uri-common intarweb json srfi-1 srfi-18)
(test-depends test srfi-1)
(author "Thomas Hintz") (author "Thomas Hintz")
(synopsis "Provides a simple interface to the SendGrid mailer service.")) (synopsis "Provides a simple interface to the SendGrid mailer service."))

View File

@@ -2,3 +2,5 @@
(uri targz "https://github.com/ThomasHintz/chicken-scheme-{egg-name}/tarball/{egg-release}") (uri targz "https://github.com/ThomasHintz/chicken-scheme-{egg-name}/tarball/{egg-release}")
(release "1") (release "1")
(release "2")
(release "2.0.1")

View File

@@ -35,7 +35,7 @@
send-mail) send-mail)
(import scheme chicken) (import scheme chicken)
(use http-client uri-common intarweb json srfi-1 srfi-18) (use data-structures http-client uri-common intarweb json srfi-1 srfi-18)
(define api-user (make-parameter "")) (define api-user (make-parameter ""))
(define api-key (make-parameter "")) (define api-key (make-parameter ""))
@@ -44,7 +44,7 @@
(vector->list (with-input-from-request (vector->list (with-input-from-request
(make-request method: method uri: (uri-reference url)) parameters json-read))) (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))) (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)) files)
(if (and subject (or text html) from from-name to reply-to) (if (and subject (or text html) from from-name to reply-to)
(rest-action "https://sendgrid.com/api/mail.send.json" 'POST (rest-action "https://sendgrid.com/api/mail.send.json" 'POST
`((api_user . ,api-user) `((api_user . ,api-user)
@@ -54,6 +54,16 @@
(replyto . ,reply-to) (replyto . ,reply-to)
,(if html `(html . ,html) `(text . ,text)) ,(if html `(html . ,html) `(text . ,text))
(from . ,from) (from . ,from)
(fromname . ,from-name))) (fromname . ,from-name)
,@(map
(lambda (file-details)
`(,(string->symbol
(string-append
"files[" (alist-ref 'filename file-details) "]"))
file: ,(alist-ref 'filepath file-details)
filename: ,(alist-ref 'filename file-details)
headers: ((content-type
,(alist-ref 'content-type file-details)))))
files)))
(abort "All parameters are required for successfully sending mail."))) (abort "All parameters are required for successfully sending mail.")))
) )

View File

@@ -11,5 +11,5 @@
; Files to install for your extension: ; Files to install for your extension:
'("send-grid.o" "send-grid.so" "send-grid.import.so") '("send-grid.o" "send-grid.so" "send-grid.import.so")
; Assoc list with properties for your extension: ; Assoc list with properties for your extension:
'((version 1) '((version 2.0.1)
(static "send-grid.o"))) ;; for static linking (static "send-grid.o"))) ;; for static linking