commit 7039653b8d8989977e8c6bafc8e17e7b6e1922c2
parent 71bbe4d3b74620adf8014f9ddc4698372c992f0b
Author: Ben Walton <bwalton@artsci.utoronto.ca>
Date: Sun, 7 Jun 2009 12:38:41 -0400
Add message bouncing capability
Bouncing a message is akin to redirecting a mail with a .forward
entry. It is passed back to the mail system as it sits on disk.
By pressing ! while viewing a message, you can now re-inject it to the
mail system using either the command defined in bounce_sendmail or the
sendmail command for the default account with any instance of -t
removed. The user is prompted for the recipients of the message and is
offered a chance to confirm the bounce before it is sent.
The message is _not_ stored in the sent box, as this doesn't make
sense with bounced messages (and would not show up uniquely anyway).
The bounce_sendmail configuration item allows users that require
different sendmail commands depending on where the bounce is destined
to write a wrapper around their local mail tools to pick and choose
the appropriate injection method for the message based on the
addresses passed in. Most systems can likely use: sendmail -oem -i
Signed-off-by: Ben Walton
Diffstat:
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -207,6 +207,7 @@ else
:confirm_top_posting => true,
:discard_snippets_from_encrypted_messages => false,
:default_attachment_save_dir => "",
+ :bounce_sendmail => "",
}
begin
FileUtils.mkdir_p Redwood::BASE_DIR
diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
@@ -41,6 +41,7 @@ EOS
# k.add :collapse_non_new_messages, "Collapse all but unread messages", 'N'
k.add :reply, "Reply to a message", 'r'
k.add :forward, "Forward a message or attachment", 'f'
+ k.add :bounce, "Bounce message to other recipient(s)", '!'
k.add :alias, "Edit alias/nickname for a person", 'i'
k.add :edit_as_new, "Edit message as new", 'D'
k.add :save_to_disk, "Save message/attachment to disk", 's'
@@ -172,6 +173,38 @@ EOS
end
end
+ def bounce
+ m = @message_lines[curpos] or return
+ to = BufferManager.ask_for_contacts(:people, "Bounce To: ") or return
+
+ defcmd = AccountManager.default_account.sendmail.sub(/\s(\-(ti|it|t))\b/) do |match|
+ case "$1"
+ when '-t' then ''
+ else ' -i'
+ end
+ end
+
+ cmd = case $config[:bounce_sendmail]
+ when nil, /^$/ then defcmd
+ else $config[:bounce_sendmail]
+ end + ' ' + to.map { |t| t.email }.join(' ')
+
+ bt = to.size > 1 ? "#{to.size} recipients" : to.to_s
+
+ if BufferManager.ask_yes_or_no "Really bounce to #{bt}?"
+ Redwood::log "Bounce Command: #{cmd}"
+ begin
+ IO.popen(cmd, 'w') do |sm|
+ sm.puts m.raw_message
+ end
+ raise SendmailCommandFailed, "Couldn't execute #{cmd}" unless $? == 0
+ rescue SystemCallError, SendmailCommandFailed => e
+ Redwood::log "Problem sending mail: #{e.message}"
+ BufferManager.flash "Problem sending mail: #{e.message}"
+ end
+ end
+ end
+
include CanAliasContacts
def alias
p = @person_lines[curpos] or return