clojure-postmark/usage/index.html @ 697d200ad349
bobbin: Update site.
author |
Steve Losh <steve@stevelosh.com> |
date |
Sun, 17 Nov 2019 18:28:54 -0500 |
parents |
8513e92c474a |
children |
(none) |
<html><head><title>Usage / clojure-postmark</title><link rel="stylesheet" href="../_dmedia/bootstrap.css"/><link rel="stylesheet" href="../_dmedia/tango.css"/><link rel="stylesheet/less" type="text/css" href="../_dmedia/style.less"/><script src="../_dmedia/less.js" type="text/javascript">
</script></head><body class="content">
<div class="wrap">
<header><h1><a href="..">clojure-postmark</a></h1></header><div class="markdown">
<h1 id="usage"><a href="">Usage</a></h1><p>First you need to load the <code>postmark</code> function:</p>
<div class="codehilite"><pre><span class="c1">; In an (ns)</span>
<span class="p">(</span><span class="nf">:use</span> <span class="p">[</span><span class="nv">postmark</span><span class="o">.</span><span class="nv">core</span> <span class="nv">:only</span> <span class="p">(</span><span class="nf">postmark</span><span class="p">)])</span>
<span class="c1">; Outside an (ns)</span>
<span class="p">(</span><span class="nf">use</span> <span class="o">'</span><span class="p">[</span><span class="nv">postmark</span><span class="o">.</span><span class="nv">core</span> <span class="nv">:only</span> <span class="p">(</span><span class="nf">postmark</span><span class="p">)])</span>
</pre></div>
<p>Create a customized <code>postmark</code> function:</p>
<div class="codehilite"><pre><span class="p">(</span><span class="k">def </span><span class="nv">pm</span> <span class="p">(</span><span class="nf">postmark</span> <span class="s">"YOUR_API_KEY"</span> <span class="s">"from-address@example.com"</span><span class="p">))</span>
</pre></div>
<p>Now just call the function to send an email:</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">pm</span> <span class="p">{</span><span class="nv">:to</span> <span class="s">"fluffy@example.com"</span>
<span class="nv">:subject</span> <span class="s">"Your Noms"</span>
<span class="nv">:text</span> <span class="s">"I wants them."</span><span class="p">})</span>
</pre></div>
<p>You can send to multiple addresses by using a seq for <code>:to</code>, but remember that
Postmark's API won't let you send to more than twenty recipients at a time:</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">pm</span> <span class="p">{</span><span class="nv">:to</span> <span class="p">[</span><span class="s">"fluffy@example.com"</span> <span class="s">"sprinkles@example.com"</span><span class="p">]</span>
<span class="nv">:subject</span> <span class="s">"All of Your Noms"</span>
<span class="nv">:text</span> <span class="s">"I wants them."</span><span class="p">})</span>
</pre></div>
<p>There are a few other keys you can use in the map you pass to the call:</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">pm</span> <span class="p">{</span><span class="nv">:to</span> <span class="p">[</span><span class="s">"fluffy@example.com"</span> <span class="s">"sprinkles@example.com"</span><span class="p">]</span>
<span class="nv">:cc</span> <span class="p">[</span><span class="s">"haiku@example.com"</span><span class="p">]</span>
<span class="nv">:bcc</span> <span class="p">[</span><span class="s">"admin@example.com"</span><span class="p">]</span>
<span class="nv">:subject</span> <span class="s">"All of Your Noms"</span>
<span class="nv">:text</span> <span class="s">"I wants them."</span>
<span class="nv">:html</span> <span class="s">"I <b>wants</b> them."</span>
<span class="nv">:tag</span> <span class="s">"Noms"</span>
<span class="nv">:reply-to</span> <span class="s">"avedon@example.com"</span><span class="p">})</span>
</pre></div>
<h2 id="testing">Testing</h2>
<p>If you just want to run a test you can use <code>postmark-test</code> without an API key
instead of <code>postmark</code>:</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">use</span> <span class="o">'</span><span class="p">[</span><span class="nv">postmark</span><span class="o">.</span><span class="nv">core</span> <span class="nv">:only</span> <span class="p">(</span><span class="nf">postmark-test</span><span class="p">)])</span>
<span class="p">(</span><span class="k">def </span><span class="nv">pt</span> <span class="p">(</span><span class="nf">postmark-test</span> <span class="s">"from-address@example.com"</span><span class="p">))</span>
<span class="p">(</span><span class="nf">pt</span> <span class="p">{</span><span class="nv">:to</span> <span class="p">[</span><span class="s">"fluffy@example.com"</span> <span class="s">"sprinkles@example.com"</span><span class="p">]</span>
<span class="nv">:subject</span> <span class="s">"Testing"</span>
<span class="nv">:text</span> <span class="s">"I might want your noms."</span><span class="p">})</span>
</pre></div>
</div>
<footer><p>Created by <a href="http://stevelosh.com">Steve Losh</a>.
Documentation created with <a href="http://sjl.bitbucket.org/d/">d</a>.</p>
<p><br/><a id="rochester-made" href="http://rochestermade.com" title="Rochester Made"><img src="http://rochestermade.com/media/images/rochester-made-dark-on-light.png" alt="Rochester Made" title="Rochester Made"/></a></p>
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4f843f8c613f5d65280000e6');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script></footer></div>
</body></html>