Created
April 29, 2014 14:39
-
-
Save temochka/11402341 to your computer and use it in GitHub Desktop.
An example of sending custom headers with postmark-rails and ActionMailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestMailer < ActionMailer::Base | |
def email | |
headers['X-Tag-Via-Hash-Access'] = 'value' | |
headers 'X-Tag-Via-Headers-Method' => 'value' | |
mail(to: '[email protected]', from: '[email protected]', subject: 'Headers test') do |format| | |
format.text { render text: 'Headers test' } | |
end | |
end | |
end | |
msg = TestMailer.email | |
# => #<Mail::Message:2203334280, Multipart: false, Headers: <From: [email protected]>, <To: [email protected]>, <Subject: Headers test>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <X-Tag-Via-Hash-Access: value>, <X-Tag-Via-Headers-Method: value>> | |
puts msg.to_postmark_hash['Headers'].inspect | |
# => [{"Name"=>"Mime-Version", "Value"=>"1.0"}, {"Name"=>"X-Tag-Via-Hash-Access", "Value"=>"value"}, {"Name"=>"X-Tag-Via-Headers-Method", "Value"=>"value"}] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment