Cleaning up setinterval’s and settimeout’s in jQUery with delay() and queue()

I came across some code that was using a tangled web of setInterval ‘s and setTimeout ‘s to do… something. I wasn’t really sure what at first.

Here’s the code:

After some investigating, I figured out two things — what the code was supposed to do, and what the code was actually doing. Continue reading “Cleaning up setinterval’s and settimeout’s in jQUery with delay() and queue()”

CC and BCC Addresses with SparkPost API

After the Mandrill that many developers grew to know and love was swallowed up by its parent MailChimp, many of us were looking for an alternative.

SparkPost emerged as what seemed like the next best thing due to its easy to use API and a generous free tier. The problem that I, and many other developers, ran into was that there is almost no documentation on how to add CC or BCC to an API response.

After some digging and a lot of trial an error, I finally found the right combination of things that worked.

CC

To add a CC address, you have to two two things

  1. Add the address to your recipients  array, and set the header_to  value to an address in the to  field. For example, if you’re sending the email to to_address@domain.com  and CCing it to cc_address@domain.com , then the header_to  for cc_address@domain.com  will need to be set to to_address@domain.com
  2. Add the email to the CC  headers  option in content  object. If you have multiple emails, these should be comma separated.

I know that’s a little confusing. See the example at the bottom of this post.

BCC

BCC Seems to be simpler than CC since it’s only one step, you just need to repeat step #1 from CC and you’re good to go.

  1. Add the address to your recipients  array, and set the header_to  value to an address in the to field. So if you’re sending the email to to_address@domain.com  and BCCing it to bcc_address@domain.com , the header_to  for bcc_address@domain.com  will need to be set to to_address@domain.com

Again, I know that’s confusing. See the example below.

Sample Request