(Context context, EntityMessage message, List<EntityAttachment> attachments, EntityIdentity identity, boolean send, MimeMessage imessage)
| 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); |
no test coverage detected