Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ In your Gemfile:

In config/initializers/mail.rb:

ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor)
ActionMailer::Base.register_interceptor(SendGridRails::MailInterceptor)

ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
Expand All @@ -30,7 +30,7 @@ In config/initializers/mail.rb:

If you use Heroku, here what the mailer initializer may look like:

ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor)
ActionMailer::Base.register_interceptor(SendGridRails::MailInterceptor)

if ENV['SENDGRID_USERNAME'] && ENV['SENDGRID_PASSWORD']
ActionMailer::Base.smtp_settings = {
Expand All @@ -53,7 +53,7 @@ By default set to '[email protected]'

In config/initializers/mail.rb:

SendGrid.configure do |config|
SendGridRails.configure do |config|
config.dummy_recipient = '[email protected]'
end

Expand Down
6 changes: 3 additions & 3 deletions lib/send_grid.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module SendGrid
module SendGridRails
autoload :ApiHeader, 'send_grid/api_header'
autoload :MailInterceptor, 'send_grid/mail_interceptor'
autoload :VERSION, 'send_grid/version'
Expand All @@ -15,7 +15,7 @@ def self.included(base)

module InstanceMethods
def send_grid_header
@send_grid_header ||= SendGrid::ApiHeader.new
@send_grid_header ||= SendGridRails::ApiHeader.new
end

def mail(headers={}, &block)
Expand All @@ -33,7 +33,7 @@ class << self
attr_writer :config

def config
@config ||= SendGrid::Config.new
@config ||= SendGridRails::Config.new
end

# Sendgrid.config will be default if block is not passed
Expand Down
2 changes: 1 addition & 1 deletion lib/send_grid/api_header.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SendGrid::ApiHeader
class SendGridRails::ApiHeader
attr_reader :data

def initialize
Expand Down
2 changes: 1 addition & 1 deletion lib/send_grid/config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SendGrid::Config
class SendGridRails::Config
attr_accessor :dummy_recipient

def initialize
Expand Down
6 changes: 1 addition & 5 deletions lib/send_grid/mail_interceptor.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
module SendGrid
module SendGridRails
class MailInterceptor
def self.delivering_email(mail)
sendgrid_header = mail.instance_variable_get(:@sendgrid_header)
sendgrid_header.add_recipients(mail.to)
sendgrid_header.add_recipients(mail.cc)
sendgrid_header.add_recipients(mail.bcc)
mail.header['X-SMTPAPI'] = sendgrid_header.to_json if sendgrid_header.data.present?
mail.header['to'] = SendGrid.config.dummy_recipient
end
end
end
5 changes: 2 additions & 3 deletions lib/send_grid/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module SendGrid
VERSION = "3.1.0"
module SendGridRails
VERSION = '3.1.0'
end

2 changes: 1 addition & 1 deletion lib/sendgrid-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
require 'active_support/core_ext'
require 'action_mailer'

ActionMailer::Base.send :include, SendGrid
ActionMailer::Base.send :include, SendGridRails
2 changes: 1 addition & 1 deletion send_grid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "send_grid/version"

Gem::Specification.new do |s|
s.name = "sendgrid-rails"
s.version = SendGrid::VERSION
s.version = SendGridRails::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["PavelTyk"]
s.email = ["[email protected]"]
Expand Down
4 changes: 2 additions & 2 deletions spec/api_header_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe SendGrid::ApiHeader do
let(:header) { SendGrid::ApiHeader.new }
describe SendGridRails::ApiHeader do
let(:header) { SendGridRails::ApiHeader.new }
describe "#to_json" do
it "returns valid json if no data was set" do
header.to_json.should eql "{}"
Expand Down
2 changes: 1 addition & 1 deletion spec/mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
it 'should be used in To defined in config dummy_recipient' do
# dummy_recipient can be redefined config/initializers

SendGrid.configure do |config|
SendGridRails.configure do |config|
config.dummy_recipient = '[email protected]'
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'sendgrid-rails'

ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor)
ActionMailer::Base.register_interceptor(SendGridRails::MailInterceptor)
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.prepend_view_path File.join(File.dirname(__FILE__), "fixtures", "views")

Expand Down
4 changes: 2 additions & 2 deletions spec/version_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'spec_helper'

describe 'SendGrid::VERSION' do
describe 'SendGridRails::VERSION' do
it "returns string" do
SendGrid::VERSION.should be_an_instance_of(String)
SendGridRails::VERSION.should be_an_instance_of(String)
end
end