* [sup-devel] [PATCH] add sendmail hook
@ 2010-09-29 14:13 Sascha Silbe
2010-09-30 0:56 ` Ben Walton
2010-10-08 4:22 ` Rich Lane
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Silbe @ 2010-09-29 14:13 UTC (permalink / raw)
To: sup-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [sup-devel] [PATCH] add sendmail hook
2010-09-29 14:13 [sup-devel] [PATCH] add sendmail hook Sascha Silbe
@ 2010-09-30 0:56 ` Ben Walton
2010-10-08 4:22 ` Rich Lane
1 sibling, 0 replies; 3+ messages in thread
From: Ben Walton @ 2010-09-30 0:56 UTC (permalink / raw)
To: sup-devel
Excerpts from Sascha Silbe's message of Wed Sep 29 10:13:00 -0400 2010:
> 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).
+1 for this. The patch looks sane although I didn't actually test it.
-Ben
Thanks
-Ben
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [sup-devel] [PATCH] add sendmail hook
2010-09-29 14:13 [sup-devel] [PATCH] add sendmail hook Sascha Silbe
2010-09-30 0:56 ` Ben Walton
@ 2010-10-08 4:22 ` Rich Lane
1 sibling, 0 replies; 3+ messages in thread
From: Rich Lane @ 2010-10-08 4:22 UTC (permalink / raw)
To: Sascha Silbe; +Cc: sup-devel
Applied to master.
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-08 4:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-29 14:13 [sup-devel] [PATCH] add sendmail hook Sascha Silbe
2010-09-30 0:56 ` Ben Walton
2010-10-08 4:22 ` Rich Lane
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox