diff --git a/lib/mandrill/web_hook/event_decorator.rb b/lib/mandrill/web_hook/event_decorator.rb index 3216d3a..02c284c 100644 --- a/lib/mandrill/web_hook/event_decorator.rb +++ b/lib/mandrill/web_hook/event_decorator.rb @@ -66,9 +66,10 @@ def headers end # Returns the email (String) of the sender. - # Applicable events: inbound + # Inbound messages: references 'from_email' message attribute. + # Send/Open/Click messages: references 'sender' message attribute. def sender_email - msg['sender'] + msg['from_email']||msg['sender'] end # Returns the subject user email address. diff --git a/spec/mandrill/web_hook/event_decorator_spec.rb b/spec/mandrill/web_hook/event_decorator_spec.rb index 2d6df70..3f5f1e6 100644 --- a/spec/mandrill/web_hook/event_decorator_spec.rb +++ b/spec/mandrill/web_hook/event_decorator_spec.rb @@ -86,7 +86,7 @@ :in_reply_to => nil, :references => [], :headers => {}, - :sender_email => nil, + :sender_email => 'from@example.com', :user_email => 'to@example.com', :recipients => [], :recipient_emails => [], @@ -113,7 +113,7 @@ :in_reply_to => nil, :references => [], :headers => {}, - :sender_email => nil, + :sender_email => 'from@example.com', :user_email => 'to@example.com', :recipients => [], :recipient_emails => [], @@ -130,7 +130,7 @@ :in_reply_to => nil, :references => [], :headers => {}, - :sender_email => nil, + :sender_email => 'from@example.com', :user_email => 'to@example.com', :recipients => [], :recipient_emails => [],