Module: SendGrid::ClassMethods

Defined in:
lib/sendgrid.rb

Instance Method Summary collapse

Instance Method Details

#sendgrid_category(category) ⇒ Object

Sets a default category for all emails. :use_subject_lines has special behavior that uses the subject-line of each outgoing email for the SendGrid category. This special behavior can still be overridden by calling sendgrid_category from within a mailer method.



42
43
44
45
46
47
# File 'lib/sendgrid.rb', line 42

def sendgrid_category(category)
  if category.length > 0 && (!self.default_sg_category || self.default_sg_category.length < 1)
    self.default_sg_category = []
  end
  self.default_sg_category.push(category)
end

#sendgrid_enable(*options) ⇒ Object

Enables a default option for all emails. See documentation for details.

Supported options:

  • :opentrack

  • :clicktrack

  • :ganalytics

  • :gravatar

  • :subscriptiontrack

  • :footer

  • :spamcheck



60
61
62
63
# File 'lib/sendgrid.rb', line 60

def sendgrid_enable(*options)
  self.default_sg_options = Array.new unless self.default_sg_options
  options.each { |option| self.default_sg_options << option if VALID_OPTIONS.include?(option) }
end

Sets the default footer text (must be enabled). Should be a hash containing the html/plain text versions:

{:html => "html version", :plain => "plan text version"}


78
79
80
# File 'lib/sendgrid.rb', line 78

def sendgrid_footer_text(texts)
  self.default_footer_text = texts
end

#sendgrid_spamcheck_maxscore(score) ⇒ Object

Sets the default spamcheck score text (must be enabled).



83
84
85
# File 'lib/sendgrid.rb', line 83

def sendgrid_spamcheck_maxscore(score)
  self.default_spamcheck_score = score
end

#sendgrid_subscriptiontrack_text(texts) ⇒ Object

Sets the default text for subscription tracking (must be enabled). There are two options:

  1. Add an unsubscribe link at the bottom of the email

{:html => "Unsubscribe <% here %>", :plain => "Unsubscribe here: <% %>"}
  1. Replace given text with the unsubscribe link

{:replace => "<unsubscribe_link>" }


71
72
73
# File 'lib/sendgrid.rb', line 71

def sendgrid_subscriptiontrack_text(texts)
  self.default_subscriptiontrack_text = texts
end