Class: Incoming::Strategies::Sendgrid
- Inherits:
-
Object
- Object
- Incoming::Strategies::Sendgrid
- Includes:
- Incoming::Strategy
- Defined in:
- lib/incoming/strategies/sendgrid.rb
Instance Attribute Summary
Attributes included from Incoming::Strategy
Instance Method Summary collapse
-
#initialize(request) ⇒ Sendgrid
constructor
A new instance of Sendgrid.
Methods included from Incoming::Strategy
Constructor Details
#initialize(request) ⇒ Sendgrid
Returns a new instance of Sendgrid.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/incoming/strategies/sendgrid.rb', line 6 def initialize(request) params = request.params.dup envelope = JSON.parse(params['envelope']) # TODO: Properly handle encodings # encodings = JSON.parse(params['charsets']) @message = Mail.new do header params['headers'] from params['from'] to envelope['to'].first subject params['subject'] body params['text'] html_part do content_type 'text/html; charset=UTF-8' body params['html'] end if params['html'] 1.upto(params['attachments'].to_i).each do |num| = params["attachment#{num}"] add_file(:filename => .original_filename, :content => .read) end end end |