My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
  Advanced search   Search tips   Subscriptions
Issue 2802: EmailMessage and reply/forward fields
24 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Jul 2011

Sign in to add a comment
Reported by, Feb 18, 2010
The EmailMessage class is a bit restrictive in the fields it stores.  For example, 
it doesn't offer In-Reply-To or References field that are important to establish 
threading support in most email applications.

While it is possible to set the fields in emailMessage.original email object, 
send() method simply ignore these fields.

Possible enhances:
1. Expose extensible fields representation to library clients, or
2. (better), add reply() and forward() methods that create new email object 
with the appropriate In-Reply-To or References field.
Dec 16, 2010
Project Member #1
(No comment was entered for this change.)
Status: Acknowledged
Labels: Component-Mail
Dec 25, 2010
Mail headers and available at AppEngine Java (1.4.0) but some of them like References and In-Reply-To are removed when sending the email. This is used for conversation view in mails like gmail and currently it's impossible to deliver mails to be included in the same thread.

Can you allow those headers?

PS: Check also the google group post about this problem:
May 16, 2011
This issue also leads to a major problem in rietveld:

Not having conversations threaded properly by open source archivers prevents the use of rietveld on many open source mailing lists.
Jul 10, 2011
Project Member #4
(No comment was entered for this change.)
Status: Started
Labels: log-1791228
Jul 21, 2011
Project Member #5
(No comment was entered for this change.)
Status: Fixed
Aug 5, 2011
Not working for me. Am setting a References header like so:

message.addHeader("References", post.getWebSafeKey());

where the web safe key is something like:


When I check the resulting email in gmail, the header is not there. My app ID is 'not-landfill'. Any ideas? Thanks.
Aug 5, 2011
It is working for us. The way we are constructing the mail is different from what you are doing though.

    if messageid is not None:

    if len(to) > 0:
    if len(cc) > 0:
    if len(attachments) > 0:

    message = mail.EmailMessage(**kwargs)

Aug 23, 2011
Using v1.5.3 of the Python SDK, I'm still unable to set the In-Reply-To or References headers in emails. In my code I have some debug/test code:

    email_msg = mail.EmailMessage(**send_args)
    email_msg.check_initialized()'Email hdrs before: "%s"', email_msg.headers)
    email_msg.headers = {'In-Reply-To': _encode_safely(in_reply_to),
                         'References': _encode_safely(in_reply_to)}'Email hdrs after: "%s"', email_msg.headers)'Email msg: "%s"', email_msg.to_mime_message())

As you can see in the log snippet from my local dev instance below (email addresses have been censored), the headers are set in the EmailMessage just fine but are not being added to the MIME message by mail_message_to_mime_message. The end result is that the email is sent without the headers, as MailServiceStub.send calls mail.MailMessageToMIMEMessage. I've attached a patch for adding the headers to the MIME message.

INFO     2011-08-23 21:50:57,760] Email hdrs before: "{'References': '<>', 'In-Reply-To': '<>'}"
INFO     2011-08-23 21:50:57,760] Email hdrs after: "{'References': '<>', 'In-Reply-To': '<>'}"
INFO     2011-08-23 21:50:57,760] Email msg: "From nobody Tue Aug 23 21:50:57 2011
Content-Type: multipart/mixed; boundary="===============8738160742719550684=="
MIME-Version: 1.0
Subject: Re: message ID test ( issue 1 )


507 bytes   View   Download
Aug 23, 2011
Project Member #9
Thanks for reporting this issue and providing the patch.

Did you try to set the headers like described in comment #7 ?
Aug 23, 2011
Yes I did set the headers as in comment #7. send_args is a dict that included the headers (as indicated by the code), and to make sure something funky wasn't happening to the dict in initialization I also manually set the headers in the EmailMessage object after creating it.

I don't know if the headers are being set properly in outgoing messages by the production appengine servers, but as of version 1.5.3 they are not being set properly by the development server run using The problem is that mail_message_to_mime_message in google/appengine/api/ never adds the MailHeaders in the MailMessage protobuf to the created MIME email object--and MailServiceStub._Send in google/appengine/api/ calls mail_message_to_mime_message (via the alias MailMessageToMIMEMessage) to create a MIME email message that is then passed to either _SendSMTP or _SendSendmail.
Aug 23, 2011
Project Member #11
Can you try to run your test in production, to see if only the SDK is impacted ?

Thanks in advance.
Labels: Component-SDK
Aug 29, 2011
I still have same problem. I use Java SDK GAE 1.5.3.
Following code does not effect on received message header:

msg.addHeader("In-Reply-To", "123");
msg.addHeader("References", "123");

Nov 14, 2011
I am having this problem also, using java sdk 1.6.0. 
I create a new message using the reply method on MimeMessage, the "In-Reply-To" and "References" are on the reply before sending it, but when it gets to the destination they are not.
Nov 28, 2011
The bug I reported in comment #8 about mail_message_to_mime_message() in google/appengine/api/ not setting the headers specified in the "header" repeated field of the MailMessage protobuf in the created MIME message is still present in version 1.6.0 of the Python SDK. As this issue is marked "Fixed" in the tracker, I have opened issue 6425 for tracking the SDK bug.
Sign in to add a comment

Powered by Google Project Hosting