Skip to content

Commit

Permalink
Explain non-delivery notification
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Dec 24, 2024
1 parent 30d8003 commit 81cd19e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/eu/faircode/email/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -4914,7 +4914,7 @@ else if (MessageHelper.FLAG_HIGH_IMPORTANCE.equals(keyword))

if (mdn && helper.isReport())
try {
MessageHelper.Report r = parts.getReport();
MessageHelper.Report r = parts.getReport(context);
boolean client_id = prefs.getBoolean("client_id", true);
String we = "dns;" + (client_id ? EmailService.getDefaultEhlo() : "example.com");
if (r != null && !we.equals(r.reporter)) {
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/eu/faircode/email/MessageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4244,7 +4244,7 @@ else if (content instanceof InputStream) {
HtmlHelper.formatPlainText(result) +
"</pre>";
} else if (h.isReport()) {
Report report = new Report(h.contentType.getBaseType(), result);
Report report = new Report(h.contentType.getBaseType(), result, context);
result = report.html;

StringBuilder w = new StringBuilder();
Expand Down Expand Up @@ -4286,7 +4286,7 @@ else if (content instanceof InputStream) {
return sb.toString();
}

Report getReport() throws MessagingException, IOException {
Report getReport(Context context) throws MessagingException, IOException {
for (PartHolder h : extra)
if (h.isReport()) {
String result;
Expand All @@ -4297,7 +4297,7 @@ else if (content instanceof InputStream)
result = Helper.readStream((InputStream) content);
else
result = content.toString();
return new Report(h.contentType.getBaseType(), result);
return new Report(h.contentType.getBaseType(), result, context);
}
return null;
}
Expand Down Expand Up @@ -6062,7 +6062,7 @@ static class Report {
String feedback;
String html;

Report(String type, String content) {
Report(String type, String content, Context context) {
this.type = type;
StringBuilder report = new StringBuilder();
report.append("<hr><div style=\"font-family: monospace; font-size: small;\">");
Expand Down Expand Up @@ -6138,7 +6138,14 @@ static class Report {
Log.e(ex);
report.append(TextUtils.htmlEncode(new ThrowableWrapper(ex).toSafeString()));
}

report.append("</div>");

if (isDeliveryStatus() && !isDelivered())
report.append("<br><div style=\"font-size: small; font-style: italic;\">")
.append(TextUtils.htmlEncode(context.getString(R.string.title_report_remark)))
.append("</div>");

this.html = report.toString();
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,7 @@
<string name="title_attachment_saved">Attachment saved</string>
<string name="title_attachments_saved">Attachments saved</string>
<string name="title_attachments_incomplete">Some attachments or images were not downloaded and could not be added</string>
<string name="title_report_remark">This report, a specially formatted email, was sent by an email server because a sent message could not be delivered to the recipient, for example because the mailbox is full, or because the email address does not exist (anymore).</string>
<string name="title_ask_save">Save changes?</string>
<string name="title_ask_delete">Delete message permanently?</string>
<string name="title_ask_delete_accept">I understand that permanently deleting messages is irreversible</string>
Expand Down

0 comments on commit 81cd19e

Please sign in to comment.