Class: Dolphin::Mailer
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- Dolphin::Mailer
- Defined in:
- lib/dolphin/mailer.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.read_iso2022_jp_mail(path, encoding_type = 'UTF-8') ⇒ Object
Examples
read_iso2022_jp_mail('/var/tmp/[email protected]')
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dolphin/mailer.rb', line 41 def self.read_iso2022_jp_mail(path, encoding_type='UTF-8') data = File.open(path, 'rb').read ec = Encoding::Converter.new("ISO-2022-JP", encoding_type) converted_data = ec.convert(data) data = converted_data.split("\r\n\r\n") header = data[0].split("\r\n") body = data[1] h = Hash.new h[:date] = header[0] h[:from] = header[1] h[:to] = header[2] h[:message_id] = header[3] h[:subject] = header[4] h[:mime_version] = header[5] h[:event_id] = header[9] h.map{|k,v| h[k] = v.split(':')[1].strip} h[:body] = body h end |
Instance Method Details
#notify(send_params) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dolphin/mailer.rb', line 63 def notify(send_params) if send_params[:from].blank? raise 'Not found from field.' end fqdn = send_params[:from].split('@')[1] m = mail(send_params) m.((send_params[:event_id], fqdn)) m.deliver end |