Archive of RubyForge sup-devel mailing list
 help / color / mirror / Atom feed
From: Sascha Silbe <sascha-pgp@silbe.org>
To: sup-devel <sup-devel@rubyforge.org>
Subject: [sup-devel] [PATCH] add sendmail hook
Date: Wed, 29 Sep 2010 16:13:00 +0200	[thread overview]
Message-ID: <1285769580-15705-1-git-send-email-sascha-pgp@silbe.org> (raw)

Add a hook that is run in place of the sendmail command. This allows
last-minute adjustments including sending a separate copy to each recipient
and setting the envelope sender, i.e. VERP (variable envelope return path).

Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org>
---
 lib/sup/modes/edit-message-mode.rb |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

I've been using this for about three months now for setting the envelope
sender to the subscription address, allowing me to use a different address
in the From: header and doing crossposts even if though I use a separate
subscription address for each mailing list.

diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index bba07b5..d80ff9b 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -58,6 +58,18 @@ Return value:
      none
 EOS

+  HookManager.register "sendmail", <<EOS
+Sends the given mail. If this hook doesn't exist, the sendmail command
+configured for the account is used.
+The message will be saved after this hook is run, so any modification to it
+will be recorded.
+Variables:
+    message: RMail::Message instance of the mail to send
+    account: Account instance matching the From address
+Return value:
+     True if mail has been sent successfully, false otherwise.
+EOS
+
   attr_reader :status
   attr_accessor :body, :header
   bool_reader :edited
@@ -341,8 +353,17 @@ protected
     begin
       date = Time.now
       m = build_message date
-      IO.popen(acct.sendmail, "w") { |p| p.puts m }
-      raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0
+
+      if HookManager.enabled? "sendmail"
+	if not HookManager.run "sendmail", :message => m, :account => acct
+          warn "Sendmail hook was not successful"
+          return false
+	end
+      else
+        IO.popen(acct.sendmail, "w") { |p| p.puts m }
+        raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0
+      end
+
       SentManager.write_sent_message(date, from_email) { |f| f.puts sanitize_body(m.to_s) }
       BufferManager.kill_buffer buffer
       BufferManager.flash "Message sent!"
--
1.7.1

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel


             reply	other threads:[~2010-09-29 14:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-29 14:13 Sascha Silbe [this message]
2010-09-30  0:56 ` Ben Walton
2010-10-08  4:22 ` Rich Lane

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285769580-15705-1-git-send-email-sascha-pgp@silbe.org \
    --to=sascha-pgp@silbe.org \
    --cc=sascha-ml-reply-to-2010-3@silbe.org \
    --cc=sup-devel@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox