Class: ActionMailer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/madmimi_for_rails_two.rb

Instance Method Summary collapse

Instance Method Details

#perform_delivery_madmimi(mail) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/madmimi_for_rails_two.rb', line 51

def perform_delivery_madmimi(mail)  
  
  form_data = { 
    'username' => MadMimi.username,
    'api_key' => MadMimi.api_key,
    'promotion_name' => promotion_name, 
    'recipients' => recipients,
    'from' => from, 
    'subject' => subject,
    'reply_to' => reply_to,
    'raw_html' => body + ' [[tracking_beacon]]'
  }
  
  http = MadMimi.connection
  
  begin
    http.start do |http|
      request = Net::HTTP::Post.new(MadMimi::SEND_PATH)
      request.set_form_data(form_data)
      response = http.request(request)
      mail.transaction_id = response.body.strip
    end
  rescue SocketError
    raise "Host unreachable."
  end
end