Open Bug 747436 Opened 9 years ago Updated 2 months ago

importing a EML file into a IMAP Gmail folder, you'll have a wrong date in GMAIL webmail

Categories

(Thunderbird :: Untriaged, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: intendentedelleacque, Unassigned, NeedInfo)

References

Details

Attachments

(1 file)

If you import a EML file into a IMAP Gmail folder, you'll have a wrong date in GMAIL webmail.

To be exact, it is not used the "Date" header, but the date and time of the moment you import the message.

I'm not sure that it depends from a Thunderbird bug or from a GMAIL bug; when uploading messages, the IMAP client is supposed to specify the "internal date" of the message as one of the arguments to the APPEND command. If the client omits this parameter, the server is supposed to use the current time. RFC 3501 section 6.3.11 states in part:

"If a date-time is specified, the internal date SHOULD be set in the resulting message; otherwise, the internal date of the resulting message is set to the current date and time by default."

I've tried to log the IMAP connection, but I can't see the details of APPEND command in the log file.
(In reply to intendentedelleacque from comment #0)
If you can attach the email to the bug (after removing private info), that would be helpful.
(In reply to intendentedelleacque from comment #0)
> when uploading messages, the IMAP client is supposed to specify the
> "internal date" of the message as one of the arguments to the APPEND
> command. If the client omits this parameter, the server is supposed to use
> the current time. RFC 3501 section 6.3.11 states in part:

You are correct.
As seen in bug 693353, Tb requests timestamp of Date: header as "internal date" upon APPEND for new version of DETACH'ed/DELETE'd mail. This was done by bug 521867. Bug 693353 can be called "a kind of regression" with some special IMAP servers due to bug 521867.

It may not be true when APPEND for import of mail like "import of mail by Drag&Drop of .eml to thread pane of IMAP folder".
Neeeded IMAP log is "log line for append command issued by Tb" only.
Required data is Date: header of the uploaded mail only.
I can see this behaviour with GMAIL both using "import of mail by Drag&Drop of .eml to thread pane" and using my extension ImportExportTools.

ImportExportTools uses nsIMsgCopyService.CopyFileMessage (and I guess that Drag&Drop uses it too).

But according to https://bug521867.bugzilla.mozilla.org/attachment.cgi?id=406525 , CopyFileMessage is setting the INTERNALDATE for APPEND correctly, isn't it? 
Does this mean that GMAIL server behaviour is wrong?

If you need some logs about it, tell me how I can have them in a useful form; with "export NSPR_LOG_MODULES=all:5" I can see that everything seems sent properly and the server response is  

14 OK [APPENDUID 2 274] (Success)

but the date shown in webmail is wrong.
Note that wrong date is just on GMAIL IMAP thread pane, but not when you open the message.
(In reply to intendentedelleacque from comment #3)
> I can see this behaviour with GMAIL both using "import of mail by Drag&Drop
> of .eml to thread pane" and using my extension ImportExportTools.
> ImportExportTools uses nsIMsgCopyService.CopyFileMessage (and I guess that
> Drag&Drop uses it too).
> But according to
> https://bug521867.bugzilla.mozilla.org/attachment.cgi?id=406525 ,
> CopyFileMessage is setting the INTERNALDATE for APPEND correctly, isn't it? 
> Does this mean that GMAIL server behaviour is wrong?

I don't know well about it, so I requested you to provide IMAP log data which shows us actual behavior of Tb in your environment.

> 14 OK [APPENDUID 2 274] (Success)

I never requested "append command response from server". I simply requested you to show us Tb's IMAP log for "append command issued by Tb upon upload" in which "internal date" is placed if Tb requested it upon append.
(In reply to intendentedelleacque from comment #5)
> Created attachment 617304 [details]
> log with upload of an EML file into a GMAIL imap server

I could see following log only by search for "append" in your log.
> -1305556112[99054f80]: 99064800:imap.gmail.com:S-INBOX:ProcessCurrentURL:imap://qqq%40gmail%2Ecom@imap.gmail.com:993/appendmsgfromfile%3E/INBOX:  = currentUrl
> -1305556112[99054f80]: 99064800:imap.gmail.com:S-INBOX:SendData: 14 append "INBOX" (\Seen) {1959}
> -1305556112[99054f80]: 99064800:imap.gmail.com:S-INBOX:CreateNewLineFromSocket: 14 OK [APPENDUID 2 274] (Success)

It looks Tb doesn't request "internal date" based Date: header upon append to upload mail data.
It explains phenomenon you observed.

What's wrong in current Tb's ehaviour?
What should Tb do when bug 693353 happens?
Component: General → Untriaged
Duplicate of this bug: 1706203

Too bad you abandoned this issue.

I'd like to refer you to internal_date in https://www.php.net/imap-append to show you how PHP deals with it.
I assume TB simply doesn't bother to set internal_date.
I believe TB should deliberately set it and it should do so based on the EML file's date header.

Flags: needinfo?(m-wada)
You need to log in before you can comment on or make changes to this bug.