Module: Tuktuk::Package
- Defined in:
- lib/tuktuk/package.rb
Class Method Summary collapse
- .build(message, index = nil) ⇒ Object
- .mixed(message) ⇒ Object
- .new(message) ⇒ Object
- .plain(message) ⇒ Object
Class Method Details
.build(message, index = nil) ⇒ Object
13 14 15 16 17 |
# File 'lib/tuktuk/package.rb', line 13 def build(, index = nil) mail = .is_a?(Hash) ? new() : .is_a?(Mail) ? : Mail.read_from_string(.to_s) mail.array_index = index if index mail end |
.mixed(message) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/tuktuk/package.rb', line 56 def mixed() mail = Mail.new do from [:from] to [:to] reply_to [:reply_to] if [:reply_to] # sender message[:sender] if message[:sender] subject [:subject] [:message_id] if [:message_id] text_part do body [:body] end html_part do content_type 'text/html; charset=UTF-8' body [:html_body] end end end |
.new(message) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tuktuk/package.rb', line 19 def new() mail = [:html_body] ? mixed() : plain() mail.charset = 'UTF-8' mail['In-Reply-To'] = [:in_reply_to] if [:in_reply_to] mail['List-Unsubscribe'] = [:list_unsubscribe] if [:list_unsubscribe] mail['List-Archive'] = [:list_archive] if [:list_archive] mail['List-Id'] = [:list_id] if [:list_id] mail['X-Mailer'] = "Tuktuk SMTP v#{Tuktuk::VERSION}" if [:return_path] mail['Return-Path'] = [:return_path] mail['Bounces-To'] = [:return_path] mail['Errors-To'] = [:return_path] end if ([:attachments] || []).any? [:attachments].each do |file| mail.add_file(file) end end mail end |
.plain(message) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tuktuk/package.rb', line 44 def plain() mail = Mail.new do from [:from] to [:to] reply_to [:reply_to] if [:reply_to] # sender message[:sender] if message[:sender] subject [:subject] [:message_id] if [:message_id] body [:body] end end |