diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 7c68943..998cdec 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -28,7 +28,7 @@ class << self :default_footer_text, :default_spamcheck_score, :default_sg_unique_args end attr_accessor :sg_category, :sg_options, :sg_disabled_options, :sg_recipients, :sg_substitutions, - :subscriptiontrack_text, :footer_text, :spamcheck_score, :sg_unique_args, :sg_send_at + :subscriptiontrack_text, :footer_text, :spamcheck_score, :sg_unique_args, :sg_send_at, :sg_batch_id end # NOTE: This commented-out approach may be a "safer" option for Rails 3, but it @@ -108,6 +108,11 @@ def sendgrid_send_at(utc_timestamp) @sg_send_at = utc_timestamp end + # Call within mailer method to set send time for this mail + def sendgrid_batch_id(batch_id) + @sg_batch_id = batch_id + end + # Call within mailer method to set unique args for this email. # Merged with class-level unique args, if any exist. def sendgrid_unique_args(unique_args = {}) @@ -228,6 +233,7 @@ def sendgrid_json_headers(mail) #Set send_at if set by the user header_opts[:send_at] = @sg_send_at unless @sg_send_at.blank? + header_opts[:batch_id] = @sg_batch_id unless @sg_batch_id.blank? # Set multi-recipients if @sg_recipients && !@sg_recipients.empty?