MCPcopy Create free account
hub / github.com/M66B/FairEmail / build

Method build

app/src/main/java/eu/faircode/email/MessageHelper.java:941–1514  ·  view source on GitHub ↗
(Context context, EntityMessage message, List<EntityAttachment> attachments, EntityIdentity identity, boolean send, MimeMessage imessage)

Source from the content-addressed store, hash-verified

939 }
940
941 static void build(Context context, EntityMessage message, List<EntityAttachment> attachments, EntityIdentity identity, boolean send, MimeMessage imessage) throws IOException, MessagingException {
942 if (EntityMessage.DSN_RECEIPT.equals(message.dsn)) {
943 // https://www.ietf.org/rfc/rfc3798.txt
944 Multipart report = new MimeMultipart("report; report-type=disposition-notification");
945
946 String html = Helper.readText(message.getFile(context));
947 String plainContent = HtmlHelper.getText(context, html);
948
949 BodyPart plainPart = new MimeBodyPart();
950 plainPart.setContent(plainContent, "text/plain; charset=" + Charset.defaultCharset().name());
951 report.addBodyPart(plainPart);
952
953 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
954 boolean client_id = prefs.getBoolean("client_id", true);
955
956 String from = null;
957 if (message.from != null && message.from.length > 0)
958 from = ((InternetAddress) message.from[0]).getAddress();
959
960 StringBuilder sb = new StringBuilder();
961
962 sb.append("Reporting-UA: ");
963 if (client_id)
964 sb.append(BuildConfig.APPLICATION_ID).append("; ")
965 .append(context.getString(R.string.app_name)).append(' ')
966 .append(BuildConfig.VERSION_NAME).append("\r\n");
967 else
968 sb.append("example.com").append("\r\n");
969
970 if (from != null)
971 sb.append("Original-Recipient: rfc822;").append(from).append("\r\n");
972
973 sb.append("Disposition: manual-action/MDN-sent-manually; displayed").append("\r\n");
974
975 BodyPart dnsPart = new MimeBodyPart();
976 dnsPart.setContent(sb.toString(), "message/disposition-notification; name=\"MDNPart2.txt\"");
977 dnsPart.setDisposition(Part.INLINE);
978 report.addBodyPart(dnsPart);
979
980 //BodyPart headersPart = new MimeBodyPart();
981 //headersPart.setContent("", "text/rfc822-headers; name=\"MDNPart3.txt\"");
982 //headersPart.setDisposition(Part.INLINE);
983 //report.addBodyPart(headersPart);
984
985 imessage.setContent(report);
986 return;
987 } else if (EntityMessage.DSN_HARD_BOUNCE.equals(message.dsn)) {
988 // https://tools.ietf.org/html/rfc3464
989 Multipart report = new MimeMultipart("report; report-type=delivery-status");
990
991 String html = Helper.readText(message.getFile(context));
992 String plainContent = HtmlHelper.getText(context, html);
993
994 BodyPart plainPart = new MimeBodyPart();
995 plainPart.setContent(plainContent, "text/plain; charset=" + Charset.defaultCharset().name());
996 report.addBodyPart(plainPart);
997
998 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

Callers 15

onExecuteMethod · 0.95
fromMethod · 0.95
initMethod · 0.45
notificationMethod · 0.45
monitorAccountMethod · 0.45
initMethod · 0.45
onExecuteMethod · 0.45
getShortcutMethod · 0.45
processOperationsMethod · 0.45
onSendMethod · 0.45

Calls 15

readTextMethod · 0.95
getTextMethod · 0.95
setContentMethod · 0.95
addBodyPartMethod · 0.95
setDispositionMethod · 0.95
getDefaultEhloMethod · 0.95
formatMethod · 0.95
parseMethod · 0.95
guessSchemesMethod · 0.95
autoLinkMethod · 0.95
encodeWebColorMethod · 0.95
getFamilyMethod · 0.95

Tested by

no test coverage detected