sendgrid 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +120 -0
- data/VERSION +1 -1
- data/lib/sendgrid.rb +38 -22
- data/sendgrid.gemspec +6 -5
- metadata +49 -22
- data/README.textile +0 -127
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,120 @@ | |
| 1 | 
            +
            sendgrid
         | 
| 2 | 
            +
            =========
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            _Now updated to work with Rails 3._
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            What is SendGrid?
         | 
| 7 | 
            +
            -----------------
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            SendGrid is an awesome service that helps you send large amounts of email (bells and whistles included) without spending large amounts of money. This gem allows for painless integration between ActionMailer and the SendGrid SMTP API. The current scope of this gem is focused around setting configuration options for outgoing email (essentially, setting categories, filters and the settings that can accompany those filters). SendGrid's service allows for some other cool stuff (such as postback notification of unsubscribes, bounces, etc.), but those features are currently outside the scope of this gem.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Visit [SendGrid](http://sendgrid.com) to learn more.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            Getting Started
         | 
| 14 | 
            +
            ---------------
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            First of all, you'll need the gem. It's at http://rubygems.org/gems/sendgrid. If you're using Bundler, just add the following to your Gemfile.
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                gem 'sendgrid'
         | 
| 19 | 
            +
             | 
| 20 | 
            +
             | 
| 21 | 
            +
            Before you can do anything with the sendgrid gem, you'll need to create your very own SendGrid account. Go ahead and do so at [http://sendgrid.com](http://sendgrid.com) (there's even a FREE account option).
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Next, update your application's SMTP settings to use SendGrid's servers (see [SendGrid's getting started guide](http://wiki.sendgrid.com/doku.php?id=get_started) for instructions).
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            Example:
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                ActionMailer::Base.smtp_settings = {
         | 
| 28 | 
            +
                  :address => "smtp.sendgrid.net",
         | 
| 29 | 
            +
                  :port => 25,
         | 
| 30 | 
            +
                  :domain => "mysite.com",
         | 
| 31 | 
            +
                  :authentication => :plain,
         | 
| 32 | 
            +
                  :user_name => "sendgrd_username@mysite.com",
         | 
| 33 | 
            +
                  :password => "sendgrid_password"
         | 
| 34 | 
            +
                }
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Using the sendgrid Gem
         | 
| 37 | 
            +
            ----------------------
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            If you do not already have an ActionMailer class up and running, then check out [this guide.](http://guides.rubyonrails.org/action_mailer_basics.html#walkthrough-to-generating-a-mailer)
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            1) add the following line within your mailer class:
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                include SendGrid
         | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
            2) customize your sendgrid settings:
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            There are 2 main types of settings
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            * Category settings
         | 
| 51 | 
            +
            * Enable/disable settings
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            You can set both global and per-email settings - the same syntax is used in either case.
         | 
| 54 | 
            +
            Here is an example of what typical usage may look like:
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                class MyMailer < ActionMailer::Base
         | 
| 57 | 
            +
                  include SendGrid
         | 
| 58 | 
            +
                  sendgrid_category :use_subject_lines
         | 
| 59 | 
            +
                  sendgrid_enable   :ganalytics, :opentracking
         | 
| 60 | 
            +
              
         | 
| 61 | 
            +
                  def welcome_message(user)
         | 
| 62 | 
            +
                    sendgrid_category "Welcome"
         | 
| 63 | 
            +
                    mail :to => user.email, :subject => "Welcome #{user.name} :-)"
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
              
         | 
| 66 | 
            +
                  def goodbye_message(to_user)
         | 
| 67 | 
            +
                    sendgrid_disable :ganalytics
         | 
| 68 | 
            +
                    mail :to => user.email, :subject => "Fare thee well :-("
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            Category settings can be any text you like and SendGrid's website will allow you to view email statistics per-category (very nice). There is also a custom global setting that will automatically use the subject line of each email as the sendgrid\_category:
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                sendgrid_category :use_subject_lines
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            If you have any dynamic subject lines, you'll want to override this setting within the mailer method. Calling sendgrid\_category from within one of your mailer methods will override this global setting. Similarly, calling sendgrid\_enable/sendgrid\_disable from within a mailer method will add or remove from any defaults that may have been set globally.
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            Here are a list of supported options for sendgrid\_enable and sendgrid\_disable:
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            * :opentrack
         | 
| 81 | 
            +
            * :clicktrack
         | 
| 82 | 
            +
            * :ganalytics
         | 
| 83 | 
            +
            * :gravatar
         | 
| 84 | 
            +
            * :subscriptiontrack
         | 
| 85 | 
            +
              * Call sendgrid\_subscriptiontrack\_text(:html => 'Unsubscribe <% Here %>', :plain => 'Unsubscribe Here: <% %>') to set a custom format for html/plain or both.
         | 
| 86 | 
            +
              * OR Call sendgrid\_subscriptiontrack\_text(:replace => '|unsubscribe\_link|') to replace all occurrences of |unsubscribe\_link| with the url of the unsubscribe link
         | 
| 87 | 
            +
            * :footer
         | 
| 88 | 
            +
              * Call sendgrid\_footer\_text(:html => 'My HTML footer rocks!', :plain => 'My plain text footer is so-so.') to set custom footer text for html, plain or both.
         | 
| 89 | 
            +
            * :spamcheck
         | 
| 90 | 
            +
              * Call sendgrid\_spamcheck\_maxscore(4.5) to set a custom SpamAssassin threshold at which SendGrid drops emails (default value is 5.0).
         | 
| 91 | 
            +
              
         | 
| 92 | 
            +
            For further explanation see [SendGrid's wiki page on filters.](http://wiki.sendgrid.com/doku.php?id=filters)
         | 
| 93 | 
            +
             | 
| 94 | 
            +
             | 
| 95 | 
            +
            Delivering to multiple recipients
         | 
| 96 | 
            +
            ---------------------------------
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            There is a per-mailer-method setting that can be used to deliver campaigns to multiple (many) recipients in a single delivery/SMTP call.
         | 
| 99 | 
            +
            It is quite easy to build a robust mass-delivery system utilizing this feature, and it is quite difficult to deliver a large email campaign quickly without this feature. 
         | 
| 100 | 
            +
            Note: While it may be worth asking yourself, a SendGrid engineer told me it's best to keep the number of recipients to <= 1,000 per delivery.
         | 
| 101 | 
            +
             | 
| 102 | 
            +
             | 
| 103 | 
            +
                sendgrid_recipients ["email1@blah.com", "email2@blah.com", "email3@blah.com", ...]
         | 
| 104 | 
            +
             | 
| 105 | 
            +
             | 
| 106 | 
            +
            One issue that arises when delivering multiple emails at once is custom content. Luckily, there is also a per-mailer-method setting that can be used to substitute custom content.
         | 
| 107 | 
            +
             | 
| 108 | 
            +
             | 
| 109 | 
            +
                sendgrid_substitute "|subme|", ["sub text for 1st recipient", "sub text for 2nd recipient", "sub text for 3rd recipient", ...]
         | 
| 110 | 
            +
             | 
| 111 | 
            +
             | 
| 112 | 
            +
            In this example, if <code>|subme|</code> is in the body of your email SendGrid will automatically substitute it for the string corresponding the recipient being delivered to. NOTE: You should ensure that the length of the substitution array is equal to the length of the recipients array.
         | 
| 113 | 
            +
             | 
| 114 | 
            +
             | 
| 115 | 
            +
            TODO
         | 
| 116 | 
            +
            ----
         | 
| 117 | 
            +
             | 
| 118 | 
            +
            * Test coverage (I would appreciate help writing tests).
         | 
| 119 | 
            +
            * Possibly integrate with SendGrid's Event API and some of the other goodies they provide.
         | 
| 120 | 
            +
             | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            1.0.0
         | 
    
        data/lib/sendgrid.rb
    CHANGED
    
    | @@ -128,32 +128,43 @@ module SendGrid | |
| 128 128 | 
             
                @spamcheck_score = score
         | 
| 129 129 | 
             
              end
         | 
| 130 130 |  | 
| 131 | 
            -
              #  | 
| 132 | 
            -
               | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 131 | 
            +
              # Call within mailer method to set unique args for this email.
         | 
| 132 | 
            +
              def sendgrid_unique_args(args)
         | 
| 133 | 
            +
                @sg_unique_args = args
         | 
| 134 | 
            +
              end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
              # only override the appropriet methods for the current rails version
         | 
| 137 | 
            +
              if Rails.version < '3.0.0'
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                # Sets the custom X-SMTPAPI header after creating the email but before delivery
         | 
| 140 | 
            +
                # NOTE: This override is used for Rails 2 ActionMailer classes. 
         | 
| 141 | 
            +
                def create!(method_name, *parameters)
         | 
| 142 | 
            +
                  super
         | 
| 143 | 
            +
                  if @sg_substitutions && !@sg_substitutions.empty?
         | 
| 144 | 
            +
                    @sg_substitutions.each do |find, replace|
         | 
| 145 | 
            +
                      raise ArgumentError.new("Array for #{find} is not the same size as the recipient array") if replace.size != @sg_recipients.size
         | 
| 146 | 
            +
                    end
         | 
| 138 147 | 
             
                  end
         | 
| 148 | 
            +
                  puts "SendGrid X-SMTPAPI: #{sendgrid_json_headers(mail)}" if Object.const_defined?("SENDGRID_DEBUG_OUTPUT") && SENDGRID_DEBUG_OUTPUT
         | 
| 149 | 
            +
                  @mail['X-SMTPAPI'] = sendgrid_json_headers(mail)
         | 
| 139 150 | 
             
                end
         | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
                     | 
| 151 | 
            +
             | 
| 152 | 
            +
              else
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                protected
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                # Sets the custom X-SMTPAPI header after creating the email but before delivery
         | 
| 157 | 
            +
                # NOTE: This override is used for Rails 3 ActionMailer classes.
         | 
| 158 | 
            +
                def mail(headers={}, &block)
         | 
| 159 | 
            +
                  super
         | 
| 160 | 
            +
                  if @sg_substitutions && !@sg_substitutions.empty?
         | 
| 161 | 
            +
                    @sg_substitutions.each do |find, replace|
         | 
| 162 | 
            +
                      raise ArgumentError.new("Array for #{find} is not the same size as the recipient array") if replace.size != @sg_recipients.size
         | 
| 163 | 
            +
                    end
         | 
| 153 164 | 
             
                  end
         | 
| 165 | 
            +
                  puts "SendGrid X-SMTPAPI: #{sendgrid_json_headers(message)}" if Object.const_defined?("SENDGRID_DEBUG_OUTPUT") && SENDGRID_DEBUG_OUTPUT
         | 
| 166 | 
            +
                  self.headers['X-SMTPAPI'] = sendgrid_json_headers(message)
         | 
| 154 167 | 
             
                end
         | 
| 155 | 
            -
                puts "SendGrid X-SMTPAPI: #{sendgrid_json_headers(message)}" if Object.const_defined?("SENDGRID_DEBUG_OUTPUT") && SENDGRID_DEBUG_OUTPUT
         | 
| 156 | 
            -
                self.headers['X-SMTPAPI'] = sendgrid_json_headers(message)
         | 
| 157 168 | 
             
              end
         | 
| 158 169 |  | 
| 159 170 | 
             
              private
         | 
| @@ -197,6 +208,11 @@ module SendGrid | |
| 197 208 | 
             
                if !enabled_opts.empty? || (@sg_disabled_options && !@sg_disabled_options.empty?)
         | 
| 198 209 | 
             
                  header_opts[:filters] = filters_hash_from_options(enabled_opts, @sg_disabled_options)
         | 
| 199 210 | 
             
                end
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                # Set unique_args
         | 
| 213 | 
            +
                if @sg_unique_args && !@sg_unique_args.empty?
         | 
| 214 | 
            +
                  header_opts[:unique_args] = @sg_unique_args
         | 
| 215 | 
            +
                end
         | 
| 200 216 |  | 
| 201 217 | 
             
                header_opts.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
         | 
| 202 218 | 
             
              end
         | 
    
        data/sendgrid.gemspec
    CHANGED
    
    | @@ -5,24 +5,24 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{sendgrid}
         | 
| 8 | 
            -
              s.version = "0. | 
| 8 | 
            +
              s.version = "1.0.0"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Stephen Blankenship"]
         | 
| 12 | 
            -
              s.date = %q{2011- | 
| 12 | 
            +
              s.date = %q{2011-06-09}
         | 
| 13 13 | 
             
              s.description = %q{This gem allows simple integration between ActionMailer and SendGrid. 
         | 
| 14 14 | 
             
                                     SendGrid is an email deliverability API that is affordable and has lots of bells and whistles.}
         | 
| 15 15 | 
             
              s.email = %q{stephenrb@gmail.com}
         | 
| 16 16 | 
             
              s.extra_rdoc_files = [
         | 
| 17 17 | 
             
                "LICENSE",
         | 
| 18 | 
            -
                "README. | 
| 18 | 
            +
                "README.md"
         | 
| 19 19 | 
             
              ]
         | 
| 20 20 | 
             
              s.files = [
         | 
| 21 21 | 
             
                ".document",
         | 
| 22 22 | 
             
                "Gemfile",
         | 
| 23 23 | 
             
                "Gemfile.lock",
         | 
| 24 24 | 
             
                "LICENSE",
         | 
| 25 | 
            -
                "README. | 
| 25 | 
            +
                "README.md",
         | 
| 26 26 | 
             
                "Rakefile",
         | 
| 27 27 | 
             
                "VERSION",
         | 
| 28 28 | 
             
                "lib/sendgrid.rb",
         | 
| @@ -32,7 +32,7 @@ Gem::Specification.new do |s| | |
| 32 32 | 
             
              ]
         | 
| 33 33 | 
             
              s.homepage = %q{http://github.com/stephenb/sendgrid}
         | 
| 34 34 | 
             
              s.require_paths = ["lib"]
         | 
| 35 | 
            -
              s.rubygems_version = %q{1. | 
| 35 | 
            +
              s.rubygems_version = %q{1.3.7}
         | 
| 36 36 | 
             
              s.summary = %q{A gem that allows simple integration of ActionMailer with SendGrid (http://sendgrid.com)}
         | 
| 37 37 | 
             
              s.test_files = [
         | 
| 38 38 | 
             
                "test/sendgrid_test.rb",
         | 
| @@ -40,6 +40,7 @@ Gem::Specification.new do |s| | |
| 40 40 | 
             
              ]
         | 
| 41 41 |  | 
| 42 42 | 
             
              if s.respond_to? :specification_version then
         | 
| 43 | 
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 43 44 | 
             
                s.specification_version = 3
         | 
| 44 45 |  | 
| 45 46 | 
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
    
        metadata
    CHANGED
    
    | @@ -1,8 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: sendgrid
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
               | 
| 5 | 
            -
               | 
| 4 | 
            +
              hash: 23
         | 
| 5 | 
            +
              prerelease: false
         | 
| 6 | 
            +
              segments: 
         | 
| 7 | 
            +
              - 1
         | 
| 8 | 
            +
              - 0
         | 
| 9 | 
            +
              - 0
         | 
| 10 | 
            +
              version: 1.0.0
         | 
| 6 11 | 
             
            platform: ruby
         | 
| 7 12 | 
             
            authors: 
         | 
| 8 13 | 
             
            - Stephen Blankenship
         | 
| @@ -10,53 +15,69 @@ autorequire: | |
| 10 15 | 
             
            bindir: bin
         | 
| 11 16 | 
             
            cert_chain: []
         | 
| 12 17 |  | 
| 13 | 
            -
            date: 2011- | 
| 18 | 
            +
            date: 2011-06-09 00:00:00 -05:00
         | 
| 14 19 | 
             
            default_executable: 
         | 
| 15 20 | 
             
            dependencies: 
         | 
| 16 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              type: :runtime
         | 
| 17 24 | 
             
              name: json
         | 
| 18 | 
            -
               | 
| 25 | 
            +
              version_requirements: &id001 !ruby/object:Gem::Requirement 
         | 
| 19 26 | 
             
                none: false
         | 
| 20 27 | 
             
                requirements: 
         | 
| 21 28 | 
             
                - - ">="
         | 
| 22 29 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 30 | 
            +
                    hash: 3
         | 
| 31 | 
            +
                    segments: 
         | 
| 32 | 
            +
                    - 0
         | 
| 23 33 | 
             
                    version: "0"
         | 
| 24 | 
            -
               | 
| 25 | 
            -
              prerelease: false
         | 
| 26 | 
            -
              version_requirements: *id001
         | 
| 34 | 
            +
              requirement: *id001
         | 
| 27 35 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 36 | 
            +
              prerelease: false
         | 
| 37 | 
            +
              type: :development
         | 
| 28 38 | 
             
              name: bundler
         | 
| 29 | 
            -
               | 
| 39 | 
            +
              version_requirements: &id002 !ruby/object:Gem::Requirement 
         | 
| 30 40 | 
             
                none: false
         | 
| 31 41 | 
             
                requirements: 
         | 
| 32 42 | 
             
                - - ~>
         | 
| 33 43 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 44 | 
            +
                    hash: 23
         | 
| 45 | 
            +
                    segments: 
         | 
| 46 | 
            +
                    - 1
         | 
| 47 | 
            +
                    - 0
         | 
| 48 | 
            +
                    - 0
         | 
| 34 49 | 
             
                    version: 1.0.0
         | 
| 35 | 
            -
               | 
| 36 | 
            -
              prerelease: false
         | 
| 37 | 
            -
              version_requirements: *id002
         | 
| 50 | 
            +
              requirement: *id002
         | 
| 38 51 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 52 | 
            +
              prerelease: false
         | 
| 53 | 
            +
              type: :development
         | 
| 39 54 | 
             
              name: jeweler
         | 
| 40 | 
            -
               | 
| 55 | 
            +
              version_requirements: &id003 !ruby/object:Gem::Requirement 
         | 
| 41 56 | 
             
                none: false
         | 
| 42 57 | 
             
                requirements: 
         | 
| 43 58 | 
             
                - - ~>
         | 
| 44 59 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 60 | 
            +
                    hash: 1
         | 
| 61 | 
            +
                    segments: 
         | 
| 62 | 
            +
                    - 1
         | 
| 63 | 
            +
                    - 5
         | 
| 64 | 
            +
                    - 1
         | 
| 45 65 | 
             
                    version: 1.5.1
         | 
| 46 | 
            -
               | 
| 47 | 
            -
              prerelease: false
         | 
| 48 | 
            -
              version_requirements: *id003
         | 
| 66 | 
            +
              requirement: *id003
         | 
| 49 67 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 68 | 
            +
              prerelease: false
         | 
| 69 | 
            +
              type: :runtime
         | 
| 50 70 | 
             
              name: json
         | 
| 51 | 
            -
               | 
| 71 | 
            +
              version_requirements: &id004 !ruby/object:Gem::Requirement 
         | 
| 52 72 | 
             
                none: false
         | 
| 53 73 | 
             
                requirements: 
         | 
| 54 74 | 
             
                - - ">="
         | 
| 55 75 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 76 | 
            +
                    hash: 3
         | 
| 77 | 
            +
                    segments: 
         | 
| 78 | 
            +
                    - 0
         | 
| 56 79 | 
             
                    version: "0"
         | 
| 57 | 
            -
               | 
| 58 | 
            -
              prerelease: false
         | 
| 59 | 
            -
              version_requirements: *id004
         | 
| 80 | 
            +
              requirement: *id004
         | 
| 60 81 | 
             
            description: |-
         | 
| 61 82 | 
             
              This gem allows simple integration between ActionMailer and SendGrid. 
         | 
| 62 83 | 
             
                                       SendGrid is an email deliverability API that is affordable and has lots of bells and whistles.
         | 
| @@ -67,13 +88,13 @@ extensions: [] | |
| 67 88 |  | 
| 68 89 | 
             
            extra_rdoc_files: 
         | 
| 69 90 | 
             
            - LICENSE
         | 
| 70 | 
            -
            - README. | 
| 91 | 
            +
            - README.md
         | 
| 71 92 | 
             
            files: 
         | 
| 72 93 | 
             
            - .document
         | 
| 73 94 | 
             
            - Gemfile
         | 
| 74 95 | 
             
            - Gemfile.lock
         | 
| 75 96 | 
             
            - LICENSE
         | 
| 76 | 
            -
            - README. | 
| 97 | 
            +
            - README.md
         | 
| 77 98 | 
             
            - Rakefile
         | 
| 78 99 | 
             
            - VERSION
         | 
| 79 100 | 
             
            - lib/sendgrid.rb
         | 
| @@ -94,17 +115,23 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 94 115 | 
             
              requirements: 
         | 
| 95 116 | 
             
              - - ">="
         | 
| 96 117 | 
             
                - !ruby/object:Gem::Version 
         | 
| 118 | 
            +
                  hash: 3
         | 
| 119 | 
            +
                  segments: 
         | 
| 120 | 
            +
                  - 0
         | 
| 97 121 | 
             
                  version: "0"
         | 
| 98 122 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 99 123 | 
             
              none: false
         | 
| 100 124 | 
             
              requirements: 
         | 
| 101 125 | 
             
              - - ">="
         | 
| 102 126 | 
             
                - !ruby/object:Gem::Version 
         | 
| 127 | 
            +
                  hash: 3
         | 
| 128 | 
            +
                  segments: 
         | 
| 129 | 
            +
                  - 0
         | 
| 103 130 | 
             
                  version: "0"
         | 
| 104 131 | 
             
            requirements: []
         | 
| 105 132 |  | 
| 106 133 | 
             
            rubyforge_project: 
         | 
| 107 | 
            -
            rubygems_version: 1. | 
| 134 | 
            +
            rubygems_version: 1.3.7
         | 
| 108 135 | 
             
            signing_key: 
         | 
| 109 136 | 
             
            specification_version: 3
         | 
| 110 137 | 
             
            summary: A gem that allows simple integration of ActionMailer with SendGrid (http://sendgrid.com)
         | 
    
        data/README.textile
    DELETED
    
    | @@ -1,127 +0,0 @@ | |
| 1 | 
            -
            h1. sendgrid
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            h3. What is SendGrid?
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            * NOTE: Now updated to work with Rails 3! *
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            SendGrid is an awesome way to send large amounts of email (bells and whistles included) without spending large amounts of money. This gem allows for painless integration between ActionMailer and the SendGrid SMTP API. The current scope of this gem is focused around setting configuration options for outgoing email (essentially, setting categories, filters and the settings that can accompany those filters). SendGrid's service allows for some other cool stuff (such as postback notification of unsubscribes, bounces, etc.), but you'll have to integrate those features on your own.
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            Visit "SendGrid":http://sendgrid.com to learn more.
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            h3. Getting Started
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            First of all, you'll need the gem. You can add sendgrid to your Rails requirements:
         | 
| 14 | 
            -
            <pre>
         | 
| 15 | 
            -
              config.gem "sendgrid", :source => 'http://gemcutter.org'
         | 
| 16 | 
            -
            </pre>
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            Or, you can install it as a gem:
         | 
| 19 | 
            -
            <pre>
         | 
| 20 | 
            -
              # if you haven't already, add gemcutter to your gem sources
         | 
| 21 | 
            -
              sudo gem install gemcutter
         | 
| 22 | 
            -
              gem tumble
         | 
| 23 | 
            -
              # install sendgrid
         | 
| 24 | 
            -
              sudo gem install sendgrid
         | 
| 25 | 
            -
            </pre>
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            Before you can do anything with the sendgrid gem, you'll need to create your very own SendGrid account. Go ahead and do so at "http://sendgrid.com":http://sendgrid.com (there's even a FREE account option).
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            Next, update your application's SMTP settings to use SendGrid's servers (see "SendGrid's getting started guide":http://wiki.sendgrid.com/doku.php?id=get_started for instructions).
         | 
| 30 | 
            -
             | 
| 31 | 
            -
            Example:
         | 
| 32 | 
            -
            <pre>
         | 
| 33 | 
            -
            ActionMailer::Base.smtp_settings = {
         | 
| 34 | 
            -
              :address => "smtp.sendgrid.net",
         | 
| 35 | 
            -
              :port => 25,
         | 
| 36 | 
            -
              :domain => "mysite.com",
         | 
| 37 | 
            -
              :authentication => :plain,
         | 
| 38 | 
            -
              :user_name => "sendgrd_username@mysite.com",
         | 
| 39 | 
            -
              :password => "sendgrid_password"
         | 
| 40 | 
            -
            }
         | 
| 41 | 
            -
            </pre>
         | 
| 42 | 
            -
             | 
| 43 | 
            -
            h3. Using the sendgrid Gem
         | 
| 44 | 
            -
             | 
| 45 | 
            -
            If you do not already have an ActionMailer class up and running, then check out "this guide.":http://guides.rubyonrails.org/action_mailer_basics.html#walkthrough-to-generating-a-mailer
         | 
| 46 | 
            -
             | 
| 47 | 
            -
            1) add the following line within your mailer class:
         | 
| 48 | 
            -
            <pre>
         | 
| 49 | 
            -
              include SendGrid
         | 
| 50 | 
            -
            </pre>
         | 
| 51 | 
            -
             | 
| 52 | 
            -
            2) customize your sendgrid settings:
         | 
| 53 | 
            -
             | 
| 54 | 
            -
            There are 2 types of settings
         | 
| 55 | 
            -
            - Category settings
         | 
| 56 | 
            -
            - Enable/disable settings
         | 
| 57 | 
            -
             | 
| 58 | 
            -
            You can set both global and per-email settings - the same syntax is used in either case.
         | 
| 59 | 
            -
            Here is an example of what typical usage may look like:
         | 
| 60 | 
            -
             | 
| 61 | 
            -
            <pre>
         | 
| 62 | 
            -
            class MyMailer < ActionMailer::Base
         | 
| 63 | 
            -
              include SendGrid
         | 
| 64 | 
            -
              sendgrid_category :use_subject_lines
         | 
| 65 | 
            -
              sendgrid_enable   :ganalytics, :opentracking
         | 
| 66 | 
            -
              
         | 
| 67 | 
            -
              def welcome_message(to_user)
         | 
| 68 | 
            -
                sendgrid_category "Welcome"
         | 
| 69 | 
            -
                
         | 
| 70 | 
            -
                recipients to_user.email
         | 
| 71 | 
            -
                subject "Welcome :-)"
         | 
| 72 | 
            -
                body :to_user => to_user
         | 
| 73 | 
            -
              end
         | 
| 74 | 
            -
              
         | 
| 75 | 
            -
              def goodbye_message(to_user)
         | 
| 76 | 
            -
                sendgrid_disable :ganalytics
         | 
| 77 | 
            -
                
         | 
| 78 | 
            -
                recipients to_user.email
         | 
| 79 | 
            -
                subject "Fare thee well :-("
         | 
| 80 | 
            -
                body :to_user => to_user
         | 
| 81 | 
            -
              end
         | 
| 82 | 
            -
            end
         | 
| 83 | 
            -
            </pre>
         | 
| 84 | 
            -
             | 
| 85 | 
            -
            Category settings can be any text you like and will allow you to view statistics per-category (very nice). There is also a custom global setting that will automatically use the subject-line of your email as the sendgrid_category:
         | 
| 86 | 
            -
            <pre>
         | 
| 87 | 
            -
              sendgrid_category :use_subject_lines
         | 
| 88 | 
            -
            </pre>
         | 
| 89 | 
            -
            Calling sendgrid_cateogry from within one of your mailer methods will override this global setting. Similarly, calling sendgrid_enable/sendgrid_disable from within a mailer method will add or remove from any defaults that may have been set globally.
         | 
| 90 | 
            -
             | 
| 91 | 
            -
            Here are a list of supported options for sendgrid_enable and sendgrid_disable:
         | 
| 92 | 
            -
            * :opentrack
         | 
| 93 | 
            -
            * :clicktrack
         | 
| 94 | 
            -
            * :ganalytics
         | 
| 95 | 
            -
            * :gravatar
         | 
| 96 | 
            -
            * :subscriptiontrack
         | 
| 97 | 
            -
            ** Call sendgrid_subscriptiontrack_text(:html => 'Unsubscribe <% Here %>', :plain => 'Unsubscribe Here: <% %>') to set a custom format for html/plain or both.
         | 
| 98 | 
            -
            ** OR Call sendgrid_subscriptiontrack_text(:replace => '.unsubscribe_link.') to replace all occurrences of .unsubscribe_link. with the url of the unsubscribe link
         | 
| 99 | 
            -
             | 
| 100 | 
            -
            * :footer
         | 
| 101 | 
            -
            ** Call sendgrid_footer_text(:html => 'My HTML footer rocks!', :plain => 'My plain text footer is so-so.') to set custom footer text for html/plain or both.
         | 
| 102 | 
            -
            * :spamcheck
         | 
| 103 | 
            -
            ** Call sendgrid_spamcheck_maxscore(4.5) to set a custom SpamAssassin threshold at which SendGrid drops emails (default value is 5.0).
         | 
| 104 | 
            -
              
         | 
| 105 | 
            -
            For further explanation see "SendGrid's wiki page on filters.":http://wiki.sendgrid.com/doku.php?id=filters
         | 
| 106 | 
            -
             | 
| 107 | 
            -
            h3. Delivering to multiple recipients
         | 
| 108 | 
            -
             | 
| 109 | 
            -
            There is a per-mailer-method setting that can be used to deliver campaigns to multiple recipients at once. You should still set the "recipients" to an address per the normal ActionMailer usage, but it will not be used.
         | 
| 110 | 
            -
             | 
| 111 | 
            -
            <pre>
         | 
| 112 | 
            -
              sendgrid_recipients ["email1@blah.com", "email2@blah.com", "email2@blah.com", ...]
         | 
| 113 | 
            -
            </pre>
         | 
| 114 | 
            -
             | 
| 115 | 
            -
            One issue that arises when delivering multiple emails at once is custom content. Luckily, there is also a per-mailer-method setting that can be used to substitute custom content.
         | 
| 116 | 
            -
             | 
| 117 | 
            -
            <pre>
         | 
| 118 | 
            -
              sendgrid_substitue "<subme>", ["sub text for 1st recipient", "sub text for 2nd recipient", "sub text for 3rd recipient", ...]
         | 
| 119 | 
            -
            </pre>
         | 
| 120 | 
            -
             | 
| 121 | 
            -
            In this example, if <code><subme></code> is in the body of your email SendGrid will automatically substitute it for the string corresponding the recipient being delivered to. NOTE: You should ensure that the length of the substitution array is equal to the length of the recipients array.
         | 
| 122 | 
            -
             | 
| 123 | 
            -
            h3. TODO
         | 
| 124 | 
            -
             | 
| 125 | 
            -
            * Test coverage (I would appreciate help writing tests).
         | 
| 126 | 
            -
            * Possibly integrate with SendGrid's Event API and some of the other goodies they provide.
         | 
| 127 | 
            -
             |