Issue 3559: Use From or ReplyTo hostname in Message-ID if available.

I wrote this fix to avoid obviously specifying that I am using a mobile device
to reply to an email.

Others want this for ease of filtering messages from their host by Message-ID.
This commit is contained in:
Mike Perry 2014-05-26 14:56:28 -07:00
parent 2fdcb77c5c
commit 7ac7fe2cfe

View file

@ -313,7 +313,22 @@ public class MimeMessage extends Message {
}
private String generateMessageId() {
return "<" + UUID.randomUUID().toString() + "@email.android.com>";
String hostname = null;
if (mFrom != null) {
int hostIdx = mFrom[0].getAddress().lastIndexOf("@");
hostname = mFrom[0].getAddress().substring(hostIdx);
}
if (hostname == null && mReplyTo != null) {
int hostIdx = mReplyTo[0].getAddress().lastIndexOf("@");
hostname = mReplyTo[0].getAddress().substring(hostIdx);
}
if (hostname != null) {
return "<" + UUID.randomUUID().toString() + hostname + ">";
} else {
return "<" + UUID.randomUUID().toString() + "@email.android.com>";
}
}
public void setMessageId(String messageId) throws UnavailableStorageException {