Open Bug 704193 Opened 13 years ago Updated 2 years ago

with IMAP, multiple drafts created from template sent to different email, if one is edited all drafts reflect same change and email send-to is changed on other drafts

Categories

(Thunderbird :: General, defect)

8 Branch
x86
Windows Vista
defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: mdmiller1, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.0; rv:8.0) Gecko/20100101 Firefox/8.0
Build ID: 20111104165243

Steps to reproduce:

in IMAP, created template.
create draft-A to individual from template and save/exit
create draft-B to another individual from template and save/exit
edit draft B and save/exit.


Actual results:

draft-A assumes changes made in draft-B, including send-to of draft-B.
summary of drafts window does not reflect this change.
if both draft-A and draft-B are sent, both email go to individual in draft-B and both email drafts include changes made in draft-B.  Draft-A disappears.


Expected results:

draft-A should not have been changed blind, only draft-B should change when editing and saving draft-B.
(In reply to mdmiller1 from comment #0)
I followed the steps you mentioned but didn't get changes done to draft-B copied to draft-A. I edited draft-B and draft-A stayed the same.

User Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111105 Thunderbird/8.0
Build ID: 20111105021619
The drafts need to be created from a template.  This does not happen with simple drafts created as originals, only when the draft was created from a template.
(In reply to mdmiller1 from comment #2)
> The drafts need to be created from a template.  This does not happen with
> simple drafts created as originals, only when the draft was created from a
> template.

Yes, I created a template and then created drafts from it.
mdmiller1 do you have extensions installed ?
I have the following extensions enabled:
lightning 1.0
quicknote 0.6.0.10
folder pane view switcher 1.7

I disabled all extensions, restarted Thunderbird and the problem as I stated above is the same and unchanged; disabling all extensions has no effect on the problem.
mdmiller1 (sorry for the delay , I have a huge number of bugmail). 

Is your draft folder an imap folder ? if so can we get an imap log reproducing the issue (see https://wiki.mozilla.org/MailNews:Logging for getting an imap log) ?
draft folder is IMAP. 
IMAP log file attached;file events as follows:
1. create template subject "test template" save to Imap Template folder
2. create email from template to testA@gmail.com and save to Imap Drafts folder
3. create email from template to testB@gmail.com and save to Imap Drafts folder
4. IMAP Drafts folder contains two draft emails, both are to testB@gmail.com
I didn't clean all of the **** out of the log file, hope you can find something that helps.  Many thanks ! !
Main cause is "Tb saves same Message-id: when Save As Draft, Save As Template".

(1) Save As Template
(1-1) Compose a mail, Save As Template
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: a1@a.a.a)
(1-2) At same composition window, change To:, second Save As Template
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: a2@a.a.a)
(1-3) Edit As New of Subject: Template-1, change To:, Save As Template
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: b1@b.b.b
(1-4) Edit As New of Subject: Template-1, without change Subject, Save As Template
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: c1@c.c.c
(2) Compose mail from Template-1, To: a1@a.a.a, Save As Draft
(2-1) Change To:, Save As Draft
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: d1@d.d.d
(2-2) Change To:, Save As Draft again
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: d2@d.d.d
(2-3) Draft at step (2-1) is deleted.
(3) Compose mail mail from Template-1, To: a2@a.a.a, Save As Draft
(3-1) Change To:, Save As Draft
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: e1@e.e.e
(3-2) Change To:, Save As Draft again
    Message-ID: <4F1E0C94.7030905@x.x.x>, Subject: Template-1, To: e2@e.e.e
(3-3) Draft at step (3-1) is deleted.

Due to same Message-Id:, following may occur.

(A) Problem in "delete old draft"
When delete of old version of draft mail, search of old draft is done by "search for Message-Id: 4F1E0C94.7030905@x.x.x" using SEARCH command of IMAP if UIDPLUS is not supported by IMAP server.
So, which draft mail is deleted depends on "which mail server returns", and if server returns multiple mails of same Message-Id:, all is up to Tb.

If Subject: is different, Tb is perhaps not confused. However, if Subject: is same too in addition to same Message-ID:, Tb may deletes oldest one. It may depend on order of returned mail from IMAP server. 

(B) "Problem in "Reply with Template" (reporte to bug 533229)
Filter rule of "If Subject contains ttt, Reply with template named Template-1(Subject:Template-1) in Templates folder under Local Folders" is saved in msgFilterRules.dat like next.
> name="reply-with-template-1"
> action="Reply"
> actionValue="mailbox://nobody@Local%20Folders/Templates?messageId=4F1E0C94.7030905@x.x.x&subject=Template-1"
> condition="AND (subject,contains,ttt)"
If multiple template mails have same Messae-ID: and same Subject:, "which template is used upon Reply with Template" is unpredictable. All is up to Tb.

(In reply to mdmiller1 from comment #7)
> Created attachment 590719 [details]
> Creating email from template in Imap folder

SEARCH command is used, and your server returns two UIDs in assending order as expected.
> 18 uid SEARCH UNDELETED HEADER Message-ID 4F1D8053.8030401@potterfactory.com
> * SEARCH 112 113
> 18 OK Search completed.

> 4. IMAP Drafts folder contains two draft emails, both are to testB@gmail.com

Tb simply uploaded(APPEND command) two different draft mail data(although same Message-Id:, same Subject:), and Tb didn't request "store Flag \Deleted" to any draft mail.
> 6 append "Drafts" (\Draft) {737+}
> Message-ID: <4F1D8053.8030401@potterfactory.com>
> To: testA@gmail.com
> Subject: test template
>
> 16 append "Drafts" (\Draft) {737+}
> Message-ID: <4F1D8053.8030401@potterfactory.com>
> To: testB@gmail.com
> Subject: test template

So, phenomenon looks like next.
- Your server perhaps keeps single copy of mail for a Messaeg-Id:+Subject: in
  mail DB, and IMAP of your server returns it for two different UIDs of same
  Messaeg-Id:+Subject:.
- SEARCH is needed upon delete of old draft. Because Tb actually issued SEARCH,
  Tb may have stopped to delete because To: is not testA@gmail.com when Tb tried 
  to delete first draft of "To: testA@gmail.com".

Anyway, root case is "Same Message-ID: which is generated by Tb". Message-ID: should be unique and is requested "universally unique". Even though "absolutely unique always on the Earth" is currently impossible, "best effort" is requested to mailer.
Tb should generate unique Message-ID: upon each Template save and Draft save, if Tb needs to pass template/draft mail data outside of Tb.
If Tb continues to generate non-unique Message-Id:, Tb must not pass template/draft mail data to outside of Tb. Problem in "reply with template of Tb" is simply a divine justice.
> 4. IMAP Drafts folder contains two draft emails, both are to testB@gmail.com

Server's behaviour was correct. In attached IMAP log, "To: testA@gmail.com" is always returned to any "uid 112 fetch" or "uid 112:N fetch", and "To: testB@gmail.com" is returned for UID=113.

At where "both are to testB@gmail.com" is seen?
Any of thread pane, message header pane, View/Message Source?
What is UID of mails? (show "Order Received" column. value is UID if IMAP).
Is Drafts offline-use=On folder? (Folder Properties/Synchronization)
Can you see it even after Folder Properties/Repair Folder of Drafts?
Further Description:
Drafts folder, all-threads view pane shows-
Subject      || Recipient || Order Received
Test template     testB@gmail.com   112
Test template     testB@gmail.com   113

Edit Action:
Both are same and Send-to is testB@gmail.com on both draft messages in edit-mode.

Viewing:
View message source of both drafts exactly the same, both are to testB@gmail.com
View message source both have exactly same time stamp Date: Mon, 23 Jan 2012 09:45:22 –0600

Properties status:
Drafts folder properties are set : offline-use=On

Repair Action taken (Properties – Repair Folder): 
Now when message is open for edit, 112 is send-to: testA@gmail.com and 113 is send-to: testB@gmail.com, BUT thread-view shows the recipient on each still to testB@gmail.com. However Message-header pane is correct, 112 send-to: testA@gmail.com and 113 send-to: testB@gmail.com
The Repair-folder appears to fix the message in message-edit-mode, and fix the message-header view, but does not fix the thread view.
As seen in IMAP log attached by you, your server correctly returns UID=112 & UID=113 for two draft mails, and your IMAP server correctly returns "To: testA@gmail.com" for UID=112 and "To: testB@gmail.com" for UID=113.
Tb is perhaps confused by "Same Message-ID: and same Subject: for different UID" which was generated by Tb himself. This is another divine justice :-)

Tb may not be confused if Subject: is different even if Message-ID: is same, even when UIDPLUS is not supported.
Is your problem observed also when different subject is set for mail of "To: testA" and "To: testB"?

Other concerns.
(a) Your server supports MULTIAPPEND but not UIDPLUS. Tb may has problem in this case.
> * CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND
>  UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS STARTTLS AUTH=PLAIN
(b) Funny "CopyNextStreamMessage: Copying 1 of 0" is seen in log.
> 6 append "Drafts" (\Draft) {737+}
> To: testA@gmail.com
> 6 OK Append completed.
> 7 noop, 7 OK NOOP completed.
> 8 uid SEARCH UNDELETED HEADER Message-ID 4F1D8053.8030401@potterfactory.com
> * SEARCH 112, 8 OK Search completed.
> Trying to select Drafts. Explicit foler open of Drafts?
> => CopyNextStreamMessage: Copying 1 of 0
> 9 noop, 9 OK NOOP completed.
> 10 UID fetch 1:* (FLAGS), * 1 FETCH (FLAGS (\Draft) UID 112), 10 OK Fetch completed.
> 11 UID fetch 112 (UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (From To ...

Workaround:
  Set different Message-ID: to template mails in Templates folder.
A way to change Message-ID: of mail data.
1. Copy all template mails to local mail folder(call FolderX).
2. Edit file named FolderX(not FolderX.msf) by text editor.
   Change Message-ID: header of each template mail.
   e.g. Insert unique string like IMAPServerName.Template.SeQNumber.
3. Delete FolderX.msf, restart Tb, Delete all mails in Templates folder,
   copy or upload template mails to Templates folder.
4. Never update template mail using Save As Template or by copy of draft.
   If update is needed, Edit As New, Save As Template, then delete old version,
   or Compose, Save As Template and never exucute Save As multiple times at the
   composed window. (Each composition window, new Message-ID is generated).
FYI.
I've opened bug 720646 for issue of comment #8(Save As Template/Draft generate mail of same Message-ID:).
Depends on: 720646
No longer blocks: 533229
Summary: changing the subjects does not impact the behavior.
TEST DRAFT FOR DIFFERENT SUBJECT:
Created two saved Drafts from templates with different subjects
Test template A  testA@gmail.com
Test template B  testB@gmail.com

Thread view incorrectly shows draft list as:
Test template B testB@gmail.com  114
Test template B testB@gmail.com  115

View source shows both exactly the same including time stamp.
Edit mode - both the same subject / recipient
Message pane - both the same subject / recipient

Run Folder Repair:
Properties repair-folder on Draft folder does not repair "recipient" in thread view which shows:
subject      ||      recipient    ||  UID
Test template A  testB@gmail.com  114
Test template B  testB@gmail.com  115
Blocks: tb-drafts
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: