Method: Vmail::ReplyTemplating#reply_headers

Defined in:
lib/vmail/reply_templating.rb

#reply_headersObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vmail/reply_templating.rb', line 16

def reply_headers
  reply_subject = current_message.subject
  if reply_subject !~ /Re: /
    reply_subject = "Re: #{reply_subject}"
  end
  date = DateTime.parse(current_message.date)
  sender = current_message.sender
  reply_quote_header = date ? "On #{date.strftime('%a, %b %d, %Y at %I:%M %p')}, #{sender} wrote:\n\n" : "#{sender} wrote:\n"

  reply_body = reply_quote_header + 
    ( current_message.plaintext.split(/^-+$/,2)[1].strip.gsub(/^(?=>)/, ">").gsub(/^(?!>)/, "> ") )

  {
    'references' => current_message.message_id,
    'from' => "#@name <#@username>", 
    'to' => reply_recipient, 
    'cc' => reply_cc, 
    'bcc' => @always_bcc,
    'subject' => reply_subject, 
    'body' => reply_body
  }
rescue
  $logger.debug $!
  raise
end