diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 1b72e1db55..cebcf52daa 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2144,6 +2144,32 @@ class Core { message.warning = Log.formatThrowable(ex, false); } + boolean check_reply = prefs.getBoolean("check_reply", false); + if (check_reply && + message.from != null && message.from.length > 0 && + message.reply != null && message.reply.length > 0) { + for (Address reply : message.reply) { + String r = ((InternetAddress) reply).getAddress(); + int rat = (r == null ? -1 : r.indexOf('@')); + if (rat > 0) { + String rdomain = r.substring(rat + 1); + for (Address from : message.from) { + String f = ((InternetAddress) from).getAddress(); + int fat = (f == null ? -1 : f.indexOf('@')); + if (fat > 0) { + String fdomain = f.substring(fat + 1); + if (!rdomain.equalsIgnoreCase(fdomain)) { + if (message.warning == null) + message.warning = context.getString(R.string.title_reply_domain, fdomain, rdomain); + else + message.warning += ", " + context.getString(R.string.title_reply_domain, fdomain, rdomain); + } + } + } + } + } + } + if (message.total != null && message.total == 0) reportEmptyMessage(context, account, istore); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java index a15f643f36..6266e9b381 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java @@ -67,10 +67,12 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr private TextView tvSubscriptionPro; private SwitchCompat swSubscribedOnly; private SwitchCompat swCheckMx; + private SwitchCompat swCheckReply; private final static String[] RESET_OPTIONS = new String[]{ "enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", - "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "subscriptions", "subscribed_only", "check_mx" + "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "subscriptions", "subscribed_only", + "check_mx", "check_reply" }; @Override @@ -107,6 +109,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro); swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly); swCheckMx = view.findViewById(R.id.swCheckMx); + swCheckReply = view.findViewById(R.id.swCheckReply); setOptions(); @@ -253,6 +256,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr } }); + swCheckReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("check_reply", checked).apply(); + } + }); + PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); return view; @@ -327,6 +337,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swSubscriptions.setEnabled(pro); swSubscribedOnly.setChecked(prefs.getBoolean("subscribed_only", false)); swCheckMx.setChecked(prefs.getBoolean("check_mx", false)); + swCheckReply.setChecked(prefs.getBoolean("check_reply", false)); } private String formatHour(Context context, int minutes) { diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 014dcd152c..6bb84a7c0c 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -206,7 +206,7 @@ app:switchPadding="12dp" /> + app:layout_constraintTop_toBottomOf="@id/tvCheckMxHint" /> + app:layout_constraintTop_toBottomOf="@id/tvCheckMxHint" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0f0c7c1a32..967fa62424 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -391,6 +391,7 @@ Synchronizing periodically will compare local and remote messages each and every time, which is an expensive operation possibly resulting in extra battery usage, especially when there are a lot of messages to synchronize. Always synchronizing will avoid this by continuous monitoring for changes only. Tap on a time to set a time Check sender email addresses on synchronizing messages + Check reply email addresses on synchronizing messages Some providers don\'t support this properly, which may cause synchronizing none or all messages This will transfer extra data and consume extra battery power, especially if a lot of messages are stored on the device Disabling this will reduce data and battery usage somewhat, but will disable updating the list of folders too @@ -398,6 +399,7 @@ In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled. This will check if DNS MX records exist + This will check if domain name of the sender and reply addresses are the same Metered connections are generally mobile connections or paid Wi-Fi hotspots Disabling this option will disable receiving and sending messages on mobile internet connections @@ -506,6 +508,7 @@ This provider does not support push messages. This will delay reception of new messages and increase battery usage. This provider does not support UTF-8 Synchronization errors since %1$s + The sender (%1$s) and reply domain (%2$s) differ An identity is required to send messages A drafts folder is required to send messages Delete this account permanently?