Open Bug 200872 Opened 21 years ago Updated 2 years ago

Pick identity for reply per folder or sender of original message (like mutt)

Categories

(MailNews Core :: Composition, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: sspitzer, Unassigned)

References

(Blocks 4 open bugs)

Details

Attachments

(2 obsolete files)

Mutt basically lets you set variables (auto-fcc, From:, signature,
really anything) based on a few things:
 - folder you're viewing when you compose/reply
 - addresses you're sending to
 - probably some other stuff, but I only use those two =)
per folder (and per sender) hooks (like mutt) for identities

from shaver

"I use them to keep my From: address mostly straight:

folder-hook (cfs|lustre) 'my_hdr From: Mike Shaver <shaver@clusterfs.com>'
folder-hook (m.o|mozbugs) 'my_hdr From: Mike Shaver <shaver@mozilla.org>'
send-hook 'llnl\.gov' 'my_hdr From: Mike Shaver <shaver@clusterfs.com>'

http://www.mutt.org/doc/manual/manual-4.html#ss4.4 has lots more,
probably clearer than the above."

for the per folder hooks, we could add a tab to the folder properties dialog.

not sure where the sender hook should go, or if there are any other killer hooks
in mutt.

while something like this is a power features, assuming the UI for them not
right in your face, they sound good.

shaver might take a whack at some of these.
shaver writes:

I was thinking that for the from-address folder-hook specialization, we
could just store the last-selected From: address in the folder's summary
file or something, and change the default to that From: when the user
switched folders.  ("Just.")  The good part of that is that there
wouldn't be any extra UI or configuration required; Mozilla would just
"remember" the last setting for that folder.  The send-hook stuff is a
little harder, but could be an address-book extension at first, followed
by a way to add an address book entry for a wildcard or something.

I'm a big fan of just having the application "remember" the last identity used
to send a message from a given folder, but I can imagine some only mildly
pathological situations where that would be a pain.  As a first step, though, I
think it would be a big step forward, and would have the nice side-effect that
the UI stuff could be deferred until we get a bit of preliminary feedback from
users.
I'll take this.  I think I'm close to having it working (modulo some polish like
a pref to disable it, and making it work in the multiple-selected-addresses
case), but I'm running into a problem with my attempts to go from a
message/folder URL-string to an nsIMsgMailNewsUrl.  I'll attach my (broken,
ugly) patch in a desperate bid for help.

(Please ignore the DEBUG_shaver removal from the XPConnect code -- I can't
handle the spam any more.)
Assignee: sspitzer → shaver
Attached patch not-yet-working patch (obsolete) — Splinter Review
The problem is in this code:

>   var mailURL = gIOService.newURI(params.originalMsgURI, null, null);
>   mailURL = mailURL.QueryInterface(Components.interfaces.nsIMsgMailNewsUrl);

The originalMsgURI is something of the form
"imap-message://shaver@localhost/moz#1", and the QI fails.  Clearly, this isn't
what I need to be doing to get the folder.  Should I be getting the nsIMessage
or whatever for the URI, and then grabbing the folder from that?  (If so, how?)
Do I just need to construct the nsIURL object through some mechanism other than
the IOService's set of parsers?
the imap-message:// is an RDF URI, not a URI as in a "real URI".

what you want is this:

var folder =
messenger.messageServiceFromURI(messageUri).messageURIToMsgHdr(messageUri).folder;

that will work for everything (news, local, imap).
Sweet.  I don't have access in the MsgComposeCommands.js code to the |messenger|
created by CreateMessenger in mailWindow.js, it seems.  I don't think I want to
create another one; should I try and get a reference to it from wherever the
mailWindow code is running?  (nsMsgWindow stuff, maybe?  seems a stretch)
Status: NEW → ASSIGNED
Attached patch working patch (obsolete) — Splinter Review
This seems to work fine for me.  Composing from the address book doesn't pick
up the identity of the currently-selected folder in Messenger, but I'm not sure
that it should.

It's not especially gorgeous (I'm thinking of the URI->folder stuff
specifically),	but I don't feel like I'm utterly defiling the code, either. 
And I resisted the urge to reindent everything I saw. =)
Attachment #119637 - Attachment is obsolete: true
Comment on attachment 119643 [details] [diff] [review]
working patch

Seth, can you take a look at this and tell me what you think?
Attachment #119643 - Flags: review?(sspitzer)
OS: Windows 2000 → All
Hardware: PC → All
I hope to look at this during 1.5 alpha.  thanks to shaver for being patient.
Target Milestone: --- → mozilla1.5alpha
asking shaver to be a little more patient.
Target Milestone: mozilla1.5alpha → mozilla1.5beta
Turns out that really, all the cool kids care about Thunderbird these days.  I'd
like to give someone this patch, for tbird, as a Christmas present.  Anyone want
to give me a hint about how to go about porting it, or should I just start from
first principles?
Mozilla 1.7, which has support for multiple identities, seems to choose an
identity for replying based on header of the letter being replied to (as I could
guess). But it selects first identity for account when composing letter from any
folder of that account. So it does not remember identity setting for folder.
Was support for remembering identity selection on per-folder basis included into
1.7 or it wiil be included later (or it will not be included at all, replaced by
some other mechanism)?
I, for one, no longer pretend that this patch will go anywhere.
Assignee: shaver → nobody
Status: ASSIGNED → NEW
Product: MailNews → Core
*** Bug 226396 has been marked as a duplicate of this bug. ***
*** Bug 277889 has been marked as a duplicate of this bug. ***
Blocks: 259976
Some notes:
1) you don't always want to use From Address from folder that is open (or was 
last opened). Ex. I looked at bugzilla mail but find a bug in my "IE-test 
project for MS" ( :-)).  I use Forward Page to forward the bad page to my 
manager at MS.  I'd want my default and top-level user id to be used -- not my
mozilla-id! :-)

2) Kmail already has something similar to this?  Isn't one of the beauties of 
open source the ability to re-use code from other open-source projects 
(providing the licenses are compatible).

3) The send-hook described by the Orig. Submitter. sounds interesting, though 
not immediately useful -- if implemented, it would have to check to change 
the "From" field only for that 1 recipient (assuming more than one).

4) For "New" messages, maybe it should default to the folder's defaults only if
1) there is a message from the folder displayed, or 2) changing to that folder
was the last action done (with window minimizing clearing that last changed 
folder);  Shouldn't use folder settings for 3rd party programs wanting to send 
mail (redux of 1)

See also: bug 166293 "Ability to tie identities to folder hierarchies (namespaces)".
*** Bug 308386 has been marked as a duplicate of this bug. ***
Blocks: 166293
Comment on attachment 119643 [details] [diff] [review]
working patch

The sands of time, etc.
Attachment #119643 - Attachment is obsolete: true
See also bug 36482 which proposes an even more generic approach.

If I'm reading it right, the patch that Mike Shaver had here was setting the identity only based on the folder; the per-sender feature wasn't addressed.
QA Contact: esther → composition
Summary: per folder (and per sender) hooks (like mutt) for identities → Pick identity for reply per folder or sender of original message (like mutt)
Target Milestone: mozilla1.5beta → ---
Bug 269491 is an RFE for making the identity a property of the original sender's address card.
If I read this bug correctly there is a extension that does the job.

Folder Account
https://addons.mozilla.org/thunderbird/2874/
*** Bug 284490 has been marked as a duplicate of this bug. ***
Product: Core → MailNews Core
Flags: wanted-seamonkey2?
Flags: blocking-seamonkey2?
Flags: blocking-seamonkey2.0b1?
Flags: blocking-seamonkey1.1.17?
Flags: blocking-seamonkey1.1.16?
Not blocking SM 2 on an enhancement request that isn't a focus of the 2.x release. Also not blocking the 1.1.x security and stability releases as they wouldn't be able to take a patch anyway.
Flags: wanted-seamonkey2?
Flags: wanted-seamonkey2+
Flags: blocking-seamonkey2?
Flags: blocking-seamonkey2.0b1?
Flags: blocking-seamonkey2.0b1-
Flags: blocking-seamonkey2-
Flags: blocking-seamonkey1.1.17?
Flags: blocking-seamonkey1.1.17-
Flags: blocking-seamonkey1.1.16?
Enhancement, not wanting on 2.0 post feature freeze any more.
Flags: wanted-seamonkey2.0+ → wanted-seamonkey2.0-
See Also: → 230247
See Also: → 355520
Surely the idea of multiple accounts is that an account is setup for each 
email identity that the user has, ie Home, work, charity etc. 
Then it make sense to keep the mail relating to that identity in folders 
in the relevant account, ie any work related emails would be kept in the 
work\inbox, or work\sent etc. 
Emails could get there by either downloading from different pop servers, 
or by dragging from another account if all incoming mails are consolidated to one server.

Composing a new message when a certain account is highlighted works correctly, 
ie the correct formatting is selected (text/html) and the correct from address 
is selected. 

When it comes to replying or forwarding a message that is highlighted, 
it should work the same way, BUT IT DOESNT !!

Please correct me if I am wrong, but I believe the solution is blatantly obvious and very simple:
1 Ignore the X-Account-Key, or add an option to ignore the X-Account-Key
2 When replying to a message, or forwarding a message, use the same subroutine that creates a new message. 
   That correctly Opens a new edit window
   Uses the correct formatting 
   Uses the correct signature, CC and Bcc addresses
   Uses the correct From address 

To cater for different setups/users then it would be sensible to have some options 
that the user could select in their preferences.
Removing myslef on all the bugs I'm cced on. Please NI me if you need something on MailNews Core bugs from me.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: