Skip to content

Commit

Permalink
add unique args header
Browse files Browse the repository at this point in the history
  • Loading branch information
yenif committed Jun 9, 2011
1 parent cddd493 commit 936ab76
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/sendgrid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ def sendgrid_spamcheck_maxscore(score)
@spamcheck_score = score
end

# Call within mailer method to set unique args for this email.
def sendgrid_unique_args(args)
@sg_unique_args = args
end

# Sets the custom X-SMTPAPI header after creating the email but before delivery
# NOTE: This override is used for Rails 2 ActionMailer classes.
def create!(method_name, *parameters)
Expand Down Expand Up @@ -197,6 +202,11 @@ def sendgrid_json_headers(mail)
if !enabled_opts.empty? || (@sg_disabled_options && !@sg_disabled_options.empty?)
header_opts[:filters] = filters_hash_from_options(enabled_opts, @sg_disabled_options)
end

# Set unique_args
if @sg_unique_args && !@sg_unique_args.empty?
header_opts[:unique_args] = @sg_unique_args
end

header_opts.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
end
Expand Down

0 comments on commit 936ab76

Please sign in to comment.