My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  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 notn...@gmail.com, 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 peter...@google.com
(No comment was entered for this change.)
Status: Acknowledged
Labels: Component-Mail
Dec 25, 2010
#2 jorgealv...@gmail.com
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:
http://groups.google.com/group/google-appengine/browse_thread/thread/b80737b41f53541f
May 16, 2011
#3 kli...@google.com
This issue also leads to a major problem in rietveld:
https://code.google.com/p/rietveld/issues/detail?id=296

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 peter...@google.com
(No comment was entered for this change.)
Status: Started
Labels: log-1791228
Jul 21, 2011
Project Member #5 ma...@google.com
(No comment was entered for this change.)
Status: Fixed
Aug 5, 2011
#6 1...@eliotstock.com
Not working for me. Am setting a References header like so:

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

where the web safe key is something like:

ag5zfm5vdC1sYW5kZmlsbHIjCxIJTG9jYWxVc2VyGIq-AwwLEgtPZmZlcmVkUG9zdBjBPgw

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
#7 mura...@bygsoft.com
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:
        kwargs.update({'headers':{'References':messageid}})

    if len(to) > 0:
	kwargs.update({'to':to})
    if len(cc) > 0:
        kwargs.update({'cc':cc})
    if len(attachments) > 0:
        kwargs.update({'attachments':attachments})

    message = mail.EmailMessage(**kwargs)
    message.send()

Aug 23, 2011
#8 ri...@google.com
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()
    logging.info('Email hdrs before: "%s"', email_msg.headers)
    email_msg.headers = {'In-Reply-To': _encode_safely(in_reply_to),
                         'References': _encode_safely(in_reply_to)}
    logging.info('Email hdrs after: "%s"', email_msg.headers)
    logging.info('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 views.py:3179] Email hdrs before: "{'References': '<20110822181154.E2160102052@illian.mtv.corp.google.com>', 'In-Reply-To': '<20110822181154.E2160102052@illian.mtv.corp.google.com>'}"
INFO     2011-08-23 21:50:57,760 views.py:3182] Email hdrs after: "{'References': '<20110822181154.E2160102052@illian.mtv.corp.google.com>', 'In-Reply-To': '<20110822181154.E2160102052@illian.mtv.corp.google.com>'}"
INFO     2011-08-23 21:50:57,760 views.py:3183] Email msg: "From nobody Tue Aug 23 21:50:57 2011
Content-Type: multipart/mixed; boundary="===============8738160742719550684=="
MIME-Version: 1.0
To: XXXXXX@XXXXXX
Cc: XXXX@XXXX
From: test@example.com
Reply-To: test@example.com, XXXXXX@XXXXXX,
        XXXX@XXXX
Subject: Re: message ID test ( issue 1 )

--===============8738160742719550684==

appengine-mail-header-fix.diff
507 bytes   View   Download
Aug 23, 2011
Project Member #9 pro...@google.com
Thanks for reporting this issue and providing the patch.

Did you try to set the headers like described in comment #7 ?
Aug 23, 2011
#10 ri...@google.com
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 dev_appserver.py. The problem is that mail_message_to_mime_message in google/appengine/api/mail.py never adds the MailHeaders in the MailMessage protobuf to the created MIME email object--and MailServiceStub._Send in google/appengine/api/mail_stub.py 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 pro...@google.com
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
#12 akapla...@gmail.com
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
#13 mcampo85@gmail.com
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
#14 ri...@google.com
The bug I reported in comment #8 about mail_message_to_mime_message() in google/appengine/api/mail.py 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