If a message was sent (To or Cc header) to an address which corresponds to an account prefer this account over the account corresponding to the address in recipient_email.
This solves the problem that the wrong reply from address is chosen on
mails which are sent to an account which is forwarded to another account.
---
lib/sup/modes/reply-mode.rb | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
index bbac922..d80f35b 100644
--- a/lib/sup/modes/reply-mode.rb
+++ b/lib/sup/modes/reply-mode.rb
@@ -65,18 +65,15 @@ EOS
## if we have a value from a hook, use it.
from = if hook_reply_from
hook_reply_from
- ## otherwise, if the original email had an envelope-to header, try and use
- ## it, and look up the corresponding name form the list of accounts.
- ##
+ ## otherwise, try and find an account somewhere in the list of to's
+ ## and cc's and look up the corresponding name form the list of accounts.
+ ## if this does not succeed use the recipient_email (=envelope-to) instead.
## this is for the case where mail is received from a mailing lists (so the
## To: is the list id itself). if the user subscribes via a particular
## alias, we want to use that alias in the reply.
- elsif @m.recipient_email && (a =
AccountManager.account_for(@m.recipient_email))
- Person.new a.name, @m.recipient_email
- ## otherwise, try and find an account somewhere in the list of to's
- ## and cc's.
- elsif(b = (@m.to + @m.cc).find { |p| AccountManager.is_account? p })
- b
+ elsif(b = (@m.to.collect {|t| t.email} + @m.cc.collect {|c| c.email} +
[[email protected]_email] ).find { |p| AccountManager.is_account_email? p })
+ a = AccountManager.account_for(b)
+ Person.new a.name, b
## if all else fails, use the default
else
AccountManager.default_account
--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~
signature.asc
Description: PGP signature
_______________________________________________ Sup-devel mailing list [email protected] http://rubyforge.org/mailman/listinfo/sup-devel
