Skip to content

Commit

Permalink
Merge pull request #5 from foca/custom-headers
Browse files Browse the repository at this point in the history
Allow configuring the email envelope
  • Loading branch information
cyx committed Sep 24, 2015
2 parents b9b6874 + 0d94384 commit 5063975
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/malone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def initialize(config)

def deliver(dict)
mail = envelope(dict)
yield mail if block_given?

smtp = Net::SMTP.new(config.host, config.port)
smtp.enable_starttls_auto if config.tls
Expand Down
9 changes: 9 additions & 0 deletions test/malone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ def SMTP.new(host, port)
assert $smtp[:finish]
end

test "adding custom headers" do |m|
m.deliver(to: "[email protected]", from: "[email protected]",
subject: "Happy new year!", text: "TEXT") do |mail|
mail.add_header("X-MC-SendAt", "2016-01-01 00:00:00")
end

assert $smtp[:blob].include?("X-MC-SendAt: 2016-01-01 00:00:00")
end

test "calls #finish even when it fails during send_message" do |m|
class FakeSMTP
def send_message(*args)
Expand Down

0 comments on commit 5063975

Please sign in to comment.