Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ea2abba7d | |||
| 70acb4f60f | |||
| 289c8cd154 |
@@ -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."))
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
(repo git "git://github.com/ThomasHintz/chicken-scheme-{egg-name}.git") ; optional
|
(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}")
|
(uri targz "https://github.com/ThomasHintz/chicken-scheme-{egg-name}/tarball/{egg-release}")
|
||||||
(release "1")
|
(release "1")
|
||||||
|
(release "2")
|
||||||
|
(release "2.0.1")
|
||||||
@@ -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.")))
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user