From 2e892022ca0b467c887bd7b7daefa97378aae7e4 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 26 Jan 2022 08:19:01 +0100 Subject: [PATCH] Added option to turn on legacy receipt request headers --- .../java/eu/faircode/email/FragmentOptionsSend.java | 13 ++++++++++++- .../main/java/eu/faircode/email/MessageHelper.java | 9 ++++++--- app/src/main/res/layout/fragment_options_send.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index cd898bbdc2..54959bdb3e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -90,6 +90,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private SwitchCompat swRemoveSignatures; private SwitchCompat swReceipt; private Spinner spReceiptType; + private SwitchCompat swReceiptLegacy; private SwitchCompat swLookupMx; private final static String[] RESET_OPTIONS = new String[]{ @@ -102,7 +103,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc "signature_location", "signature_new", "signature_reply", "signature_forward", "discard_delete", "reply_move", "auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures", - "receipt_default", "receipt_type", "lookup_mx" + "receipt_default", "receipt_type", "receipt_legacy", "lookup_mx" }; @Override @@ -154,6 +155,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swRemoveSignatures = view.findViewById(R.id.swRemoveSignatures); swReceipt = view.findViewById(R.id.swReceipt); spReceiptType = view.findViewById(R.id.spReceiptType); + swReceiptLegacy = view.findViewById(R.id.swReceiptLegacy); swLookupMx = view.findViewById(R.id.swLookupMx); String[] fontNameNames = getResources().getStringArray(R.array.fontNameNames); @@ -474,6 +476,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } }); + swReceiptLegacy.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("receipt_legacy", checked).apply(); + } + }); + swLookupMx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -598,6 +607,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc int receipt_type = prefs.getInt("receipt_type", 2); spReceiptType.setSelection(receipt_type); + swReceiptLegacy.setChecked(prefs.getBoolean("receipt_legacy", false)); + swLookupMx.setChecked(prefs.getBoolean("lookup_mx", false)); } } diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 4205e384f7..2321d1ef60 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -253,6 +253,7 @@ public class MessageHelper { DB db = DB.getInstance(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int receipt_type = prefs.getInt("receipt_type", 2); + boolean receipt_legacy = prefs.getBoolean("receipt_legacy", false); boolean hide_timezone = prefs.getBoolean("hide_timezone", true); boolean autocrypt = prefs.getBoolean("autocrypt", true); boolean mutual = prefs.getBoolean("autocrypt_mutual", true); @@ -449,9 +450,11 @@ public class MessageHelper { // 2=Read+delivery receipt // defacto standard - if (receipt_type == 1 || receipt_type == 2) // Delivery receipt - imessage.addHeader("Return-Receipt-To", to); - + if (receipt_type == 1 || receipt_type == 2) { + // Delivery receipt + if (receipt_legacy) + imessage.addHeader("Return-Receipt-To", to); + } // https://tools.ietf.org/html/rfc3798 if (receipt_type == 0 || receipt_type == 2) { diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index fb912755e5..ef9bf66af3 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -738,6 +738,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvReceiptType" /> + + Most servers do not support this Maximum message size (MB) Request delivery/read receipt by default + Use legacy receipt request headers In case of \'invalid greeting\', \'requires valid address\' or a similar error, try to change this setting Also prevents you from replying to yourself Optional