<commit_before>[![Gem Version](https://badge.fury.io/rb/sparkpost_rails.svg)](https://badge.fury.io/rb/sparkpost_rails)
[![Build Status](https://travis-ci.org/the-refinery/sparkpost_rails.svg?branch=master)](https://travis-ci.org/the-refinery/sparkpost_rails)

SparkPost Rails
===============

This gem provides seamless integration of SparkPost with ActionMailer. It provides a delivery_method based upon the SparkPost API, and
makes getting setup and sending email via SparkPost in a Rails app pretty painless.

Getting Started
---------------

Add the gem to your Gemfile

```
gem 'sparkpost_rails'
```

Then run the bundle command to install it.

By default, the gem will look for your SparkPost API key in your environment, with the key 'SPARKPOST_API_KEY'.  You can override this 
setting by identifying a different key in the initializer (`config/initializers/sparkpost_rails.rb`):

```
SparkPostRails.configure do |c|
  c.api_key = 'YOUR API KEY'
end
```

In each environment configuration file from which you want to send emails via Sparkpost, (i.e. `config/environments/production.rb`) add

```
config.action_mailer.delivery_method = :sparkpost
```

Additional Configuration
------------------------
You can establish values for a number of SparkPost settings in the initializer.  These values will be used for every message sent 
from your application.  You can override these settings on individual messages.

```
SparkPostRails.configure do |c|
  c.sandbox = true
  c.track_opens = true
  c.track_clicks = true
  c.return_path = 'BOUNCE-<EMAIL>-<EMAIL>'<commit_msg>Updated README to reflect that an initializer file is not required<commit_after>[![Gem Version](https://badge.fury.io/rb/sparkpost_rails.svg)](https://badge.fury.io/rb/sparkpost_rails)
[![Build Status](https://travis-ci.org/the-refinery/sparkpost_rails.svg?branch=master)](https://travis-ci.org/the-refinery/sparkpost_rails)

SparkPost Rails
===============

This gem provides seamless integration of SparkPost with ActionMailer. It provides a delivery_method based upon the SparkPost API, and
makes getting setup and sending email via SparkPost in a Rails app pretty painless.

Getting Started
---------------

Add the gem to your Gemfile

```
gem 'sparkpost_rails'
```

Then run the bundle command to install it.

By default, the gem will look for your SparkPost API key in your environment, with the key 'SPARKPOST_API_KEY'.  You can override this 
setting by identifying a different key in the initializer (`config/initializers/sparkpost_rails.rb`):

```
SparkPostRails.configure do |c|
  c.api_key = 'YOUR API KEY'
end
```
Note that an initializer file is not required to use this gem. If an initializer is not provided, default values will be used. See ["Additional Configuration"](#additional-configuration) below for a list of all the default settings.

In each environment configuration file from which you want to send emails via Sparkpost, (i.e. `config/environments/production.rb`) add

```
config.action_mailer.delivery_method = :sparkpost
```

Additional Configuration
------------------------
You can establish values for a number of SparkPost settings in the initializer.  These values will be used for every message sent 
from your application.  You can override these settings on individual messages.

```
SparkPostRails.configure do |c|
  c.sandbox = true
  c.track_opens = true
  c.track_clicks = true
  c.return_path = '<EMAIL>'
{'fraction_non_alphanumeric': 0.1143857601400642, 'fraction_numerical': 0.0, 'mean_word_length': 4.339563862928349, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3559470', 'n_tokens_mistral': 1047, 'n_tokens_neox': 968, 'n_words': 368}