Browse Source

Fixed setting JavaMail properties

main
M66B 6 years ago
parent
commit
15d7b0606f
2 changed files with 14 additions and 20 deletions
  1. +14
    -10
      app/src/main/java/eu/faircode/email/MessageHelper.java
  2. +0
    -10
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 14
- 10
app/src/main/java/eu/faircode/email/MessageHelper.java View File

@ -112,6 +112,11 @@ public class MessageHelper {
props.put("mail.mime.address.strict", "false");
props.put("mail.mime.decodetext.strict", "false");
props.put("mail.mime.ignoreunknownencoding", "true");
props.put("mail.mime.decodefilename", "true");
props.put("mail.mime.encodefilename", "true");
props.put("mail.mime.multipart.ignoreexistingboundaryparameter", "true");
// https://javaee.github.io/javamail/OAuth2
Log.i(Helper.TAG, "Auth type=" + auth_type);
if (auth_type == Helper.AUTH_TYPE_GMAIL) {
@ -278,21 +283,20 @@ public class MessageHelper {
private String getHtml(Part part) throws MessagingException, UnsupportedEncodingException {
if (part.isMimeType("text/*"))
try {
String s;
if ("x-binaryenc".equals(part.getContentType())) {
InputStream is = part.getInputStream();
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
for (int len = is.read(buffer); len != -1; len = is.read(buffer))
os.write(buffer, 0, len);
s = new String(os.toByteArray(), "US-ASCII");
} else
s = part.getContent().toString();
String s = part.getContent().toString();
if (part.isMimeType("text/plain"))
s = "<pre>" + s.replaceAll("\\r?\\n", "<br />") + "</pre>";
return s;
} catch (UnsupportedEncodingException ex) {
// https://javaee.github.io/javamail/FAQ#unsupen
//if ("x-binaryenc".equals(part.getContentType())) {
// InputStream is = part.getInputStream();
// ByteArrayOutputStream os = new ByteArrayOutputStream();
// byte[] buffer = new byte[4096];
// for (int len = is.read(buffer); len != -1; len = is.read(buffer))
// os.write(buffer, 0, len);
// s = new String(os.toByteArray(), "US-ASCII");
//}
throw new UnsupportedEncodingException(part.getContentType());
} catch (IOException ex) {


+ 0
- 10
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -127,15 +127,6 @@ public class ServiceSynchronize extends LifecycleService {
static final String ACTION_SYNCHRONIZE_FOLDER = BuildConfig.APPLICATION_ID + ".SYNCHRONIZE_FOLDER";
static final String ACTION_PROCESS_OPERATIONS = BuildConfig.APPLICATION_ID + ".PROCESS_OPERATIONS";
public ServiceSynchronize() {
// https://docs.oracle.com/javaee/6/api/javax/mail/internet/package-summary.html
// https://docs.oracle.com/javaee/6/api/javax/mail/internet/MimeMultipart.html
System.setProperty("mail.mime.ignoreunknownencoding", "true");
System.setProperty("mail.mime.decodefilename", "true");
System.setProperty("mail.mime.encodefilename", "true");
System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", "true");
}
@Override
public void onCreate() {
Log.i(Helper.TAG, "Service create version=" + BuildConfig.VERSION_NAME);
@ -419,7 +410,6 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(Helper.TAG, account.name + " event: " + e.getMessage());
db.account().setAccountError(account.id, e.getMessage());
synchronized (state) {
state.notifyAll();
}


Loading…
Cancel
Save