Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to fetch inbound_hash value from email.to property #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Postmark-mitt has been verified to work on Ruby Enterprise Edition 1.8.7, 1.9.2
email = Postmark::Mitt.new(request.body.read)

email.to # "[email protected]"
email.inbound_hash # "api-hash"
email.from # Bob Bobson <[email protected]>
email.from_email # [email protected]
email.text_body
Expand Down
4 changes: 4 additions & 0 deletions lib/postmark/mitt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def to_email
to_full.any? ? to_full.first["Email"] : to
end

def inbound_hash
to_full.any? ? to_email.split("@").first : to
end

def to_name
to_full.any? ? to_full.first["Name"] : to
end
Expand Down
6 changes: 5 additions & 1 deletion spec/postmark/mitt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
mitt.to_email.should == "[email protected]"
end

it "should pull out the to_inbound_hash" do
mitt.inbound_hash.should == "api-hash"
end


it "should be from someone" do
mitt.from.should == "Bob Bobson <[email protected]>"
Expand Down Expand Up @@ -175,7 +179,7 @@
instance = ::Postmark::MittTempfile.new("file/with/../path", "text/csv")
}.to_not raise_error
end

it "should escape path chars" do
instance = ::Postmark::MittTempfile.new("file/with/../path", "text/csv")
instance.path.should include("file-with-..-path")
Expand Down