Sha256: d1ca27efcadcd79444f04a1d24ad6cb92522f2d13a804bd5e99a9c6d1959f5d0
Contents?: true
Size: 1.57 KB
Versions: 6
Compression:
Stored size: 1.57 KB
Contents
# encoding: UTF-8 require 'mail' require 'time' module Vmail module ReplyTemplating def reply_template(replyall=false) @replyall = replyall log "Sending reply template" h = reply_headers body = h.delete('body') format_headers(h) + "\n\n\n" + body + signature end 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 + divider('-') + (current_message.plaintext.split(/^-+$/,2)[1]) { 'message-id' => 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 def reply_recipient current_mail.header['Reply-To'] || current_message.sender end def reply_cc return nil unless (@replyall || @always_cc) xs = if @replyall ((current_mail['cc'] && current_mail['cc'].decoded) || "") .split(/,\s*/) else [] end if @always_cc && xs.none? {|x| x =~ %r{#{@always_cc}}} xs << @always_cc end xs.uniq.select {|x| x != reply_recipient }.join(', ') end end end
Version data entries
6 entries across 6 versions & 1 rubygems