/^(In-Reply-To):\s+(.*?)\s*$/i,
/^(Reply-To):\s+(.*?)\s*$/i,
/^(List-Post):\s+(.*?)\s*$/i,
+ /^(List-Subscribe):\s+(.*?)\s*$/i,
+ /^(List-Unsubscribe):\s+(.*?)\s*$/i,
/^(Status):\s+(.*?)\s*$/i: header[last = $1] = $2
when /^(Message-Id):\s+(.*?)\s*$/i: header[mid_field = last = $1] = $2
/^(Envelope-To):\s+(.*)$/i: header[last = $1] ||= $2
when /^$/: break
- when /:/: last = nil # some other header we don't care about
+ when /^\S+: /: last = nil # some other header we don't care about
else
header[last] += " " + line.chomp.gsub(/^\s+/, "") if last
end
attr_reader :id, :date, :from, :subj, :refs, :replytos, :to, :source,
:cc, :bcc, :labels, :list_address, :recipient_email, :replyto,
- :source_info, :chunks
+ :source_info, :chunks, :list_subscribe, :list_unsubscribe
bool_reader :dirty, :source_marked_read
@recipient_email = header["envelope-to"] || header["x-original-to"] || header["delivered-to"]
@source_marked_read = header["status"] == "RO"
+ @list_subscribe = header["list-subscribe"]
+ @list_unsubscribe = header["list-unsubscribe"]
end
private :parse_header
bcc = opts[:bcc] || BufferManager.ask_for_contacts(:people, "Bcc: ") or return if $config[:ask_for_bcc]
subj = opts[:subj] || BufferManager.ask(:subject, "Subject: ") or return if $config[:ask_for_subject]
- mode = ComposeMode.new :to => to, :cc => cc, :bcc => bcc, :subj => subj
+ mode = ComposeMode.new :from => opts[:from], :to => to, :cc => cc, :bcc => bcc, :subj => subj
BufferManager.spawn "New Message", mode
mode.edit_message
end
class ComposeMode < EditMessageMode
def initialize opts={}
- header = {
- "From" => AccountManager.default_account.full_address,
- }
-
+ header = {}
+ header["From"] = (opts[:from] || AccountManager.default_account).full_address
+ header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to]
header["To"] = opts[:to].map { |p| p.full_address }.join(", ") if opts[:to]
header["Cc"] = opts[:cc].map { |p| p.full_address }.join(", ") if opts[:cc]
header["Bcc"] = opts[:bcc].map { |p| p.full_address }.join(", ") if opts[:bcc]
k.add :compose, "Compose message to person", 'm'
k.add :archive_and_kill, "Archive thread and kill buffer", 'a'
k.add :delete_and_kill, "Delete thread and kill buffer", 'd'
+ k.add :subscribe_to_list, "Subscribe to/unsubscribe from mailing list", "("
+ k.add :unsubscribe_from_list, "Subscribe to/unsubscribe from mailing list", ")"
end
## there are a couple important instance variables we hold to format
BufferManager.spawn "Reply to #{m.subj}", mode
end
+ def subscribe_to_list
+ m = @message_lines[curpos] or return
+ if m.list_subscribe && m.list_subscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
+ spawn_compose_mode :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+ else
+ BufferManager.flash "Can't find List-Subscribe header for this message."
+ end
+ end
+
+ def unsubscribe_from_list
+ m = @message_lines[curpos] or return
+ if m.list_unsubscribe && m.list_unsubscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
+ spawn_compose_mode :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+ else
+ BufferManager.flash "Can't find List-Unsubscribe header for this message."
+ end
+ end
+
def forward
m = @message_lines[curpos] or return
spawn_forward_mode m