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:
parent
2fdcb77c5c
commit
7ac7fe2cfe
1 changed files with 16 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue