diff --git a/lib/sendgrid.rb b/lib/sendgrid.rb index 0ce9caf..23dffe6 100644 --- a/lib/sendgrid.rb +++ b/lib/sendgrid.rb @@ -141,7 +141,7 @@ def sendgrid_unique_args(args) # Sets the custom X-SMTPAPI header after creating the email but before delivery # NOTE: This override is used for Rails 3 ActionMailer classes. def mail(headers={}, &block) - super + m = super if @sg_substitutions && !@sg_substitutions.empty? @sg_substitutions.each do |find, replace| raise ArgumentError.new("Array for #{find} is not the same size as the recipient array") if replace.size != @sg_recipients.size @@ -149,6 +149,7 @@ def mail(headers={}, &block) end puts "SendGrid X-SMTPAPI: #{sendgrid_json_headers(message)}" if Object.const_defined?("SENDGRID_DEBUG_OUTPUT") && SENDGRID_DEBUG_OUTPUT self.headers['X-SMTPAPI'] = sendgrid_json_headers(message) + m end else