diff --git a/src/com/fsck/k9/mail/Address.java b/src/com/fsck/k9/mail/Address.java index b49f425c0..a8ef1ee0c 100644 --- a/src/com/fsck/k9/mail/Address.java +++ b/src/com/fsck/k9/mail/Address.java @@ -93,6 +93,16 @@ public class Address { return mAddress; } + public String getHostname() { + int hostIdx = mAddress.lastIndexOf("@"); + + if (hostIdx == -1) { + return null; + } + + return mAddress.substring(hostIdx+1); + } + public void setAddress(String address) { this.mAddress = address; } diff --git a/src/com/fsck/k9/mail/internet/MimeMessage.java b/src/com/fsck/k9/mail/internet/MimeMessage.java index 7c6fe6b2c..2f69cba39 100644 --- a/src/com/fsck/k9/mail/internet/MimeMessage.java +++ b/src/com/fsck/k9/mail/internet/MimeMessage.java @@ -321,21 +321,21 @@ public class MimeMessage extends Message { private String generateMessageId() { String hostname = null; - if (mFrom != null) { - int hostIdx = mFrom[0].getAddress().lastIndexOf("@"); - hostname = mFrom[0].getAddress().substring(hostIdx); + + if (mFrom != null && mFrom.length >= 1) { + hostname = mFrom[0].getHostname(); } - if (hostname == null && mReplyTo != null) { - int hostIdx = mReplyTo[0].getAddress().lastIndexOf("@"); - hostname = mReplyTo[0].getAddress().substring(hostIdx); + if (hostname == null && mReplyTo != null && mReplyTo.length >= 1) { + hostname = mReplyTo[0].getHostname(); } - if (hostname != null) { - return "<" + UUID.randomUUID().toString() + hostname + ">"; - } else { - return "<" + UUID.randomUUID().toString() + "@email.android.com>"; + if (hostname == null) { + hostname = "email.android.com"; } + + /* We use upper case here to match Apple Mail Message-ID format (for privacy) */ + return "<" + UUID.randomUUID().toString().toUpperCase(Locale.US) + "@" + hostname + ">"; } public void setMessageId(String messageId) throws UnavailableStorageException { diff --git a/src/com/fsck/k9/preferences/Settings.java b/src/com/fsck/k9/preferences/Settings.java index 11ecc921a..b4dd8ef41 100644 --- a/src/com/fsck/k9/preferences/Settings.java +++ b/src/com/fsck/k9/preferences/Settings.java @@ -35,7 +35,7 @@ public class Settings { * * @see SettingsExporter */ - public static final int VERSION = 31; + public static final int VERSION = 32; public static Map validate(int version, Map> settings,