sparks
is a command-line tool for sending email using the SparkPost API.
I've found this tool useful for testing and troubleshooting, and for making sure that reported issues with gosparkpost
get squashed. It also has handy working example code showing how to use the gosparkpost
library to do various things, like using inline images, adding attachments, and managing cc/bcc recipients.
It's similar in function to swaks, which is a handy SMTP tool: Swiss Army Knife for SMTP
, and sparks
sounded better than swaksp
, swakapi
or apisak
, etc.
$ go get [email protected]:SparkPost/gosparkpost
$ cd $GOPATH/src/github.com/SparkPost/gosparkpost/cmd/sparks
$ go build && go install
$ export SPARKPOST_API_KEY=0000000000000000000000000000000000000000
HTML content with inline image, dumping request and response HTTP headers, and response body.
$ sparks -from [email protected] -html $HOME/test/image.html \
-img image/jpg:hi:$HOME/test/hi.jpg -subject 'hello!' \
-to [email protected] -httpdump
HTML content with attachment.
$ sparks -from [email protected] -html 'Did you get that <i>thing</i> I sent you?' \
-to [email protected] -subject 'that thing' \
-attach image/jpg:thing.jpg:$HOME/test/thing.jpg
Text content with cc and bcc, but don't send it.
The output that would be sent is pretty printed using the handy JSON tool jq
.
$ sparks -from [email protected] -text 'This is an ambiguous notification' \
-subject 'ambiguous notification' \
-to [email protected] \
-cc [email protected] \
-bcc [email protected] \
-bcc [email protected] \
-dry-run | jq .