|
|
@ -294,7 +294,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
.setSmallIcon(R.drawable.baseline_warning_white_24)
|
|
|
|
.setSmallIcon(R.drawable.baseline_warning_white_24)
|
|
|
|
.setContentTitle(getString(R.string.title_notification_sending_failed, recipient))
|
|
|
|
.setContentTitle(getString(R.string.title_notification_sending_failed, recipient))
|
|
|
|
.setContentIntent(getPendingIntent(this))
|
|
|
|
.setContentIntent(getPendingIntent(this))
|
|
|
|
.setAutoCancel(tries_left != 0)
|
|
|
|
.setAutoCancel(true)
|
|
|
|
.setShowWhen(true)
|
|
|
|
.setShowWhen(true)
|
|
|
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
|
|
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
|
|
|
.setOnlyAlertOnce(false)
|
|
|
|
.setOnlyAlertOnce(false)
|
|
|
@ -573,7 +573,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
// Requeue non executing operations
|
|
|
|
// Requeue non executing operations
|
|
|
|
for (long id : db.message().getMessageByFolder(outbox.id)) {
|
|
|
|
for (long id : db.message().getMessageByFolder(outbox.id)) {
|
|
|
|
EntityMessage message = db.message().getMessage(id);
|
|
|
|
EntityMessage message = db.message().getMessage(id);
|
|
|
|
if (message == null)
|
|
|
|
if (message == null || message.warning != null)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
EntityOperation op = db.operation().getOperation(message.id, EntityOperation.SEND);
|
|
|
|
EntityOperation op = db.operation().getOperation(message.id, EntityOperation.SEND);
|
|
|
@ -623,6 +623,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService(true));
|
|
|
|
nm.notify(NotificationHelper.NOTIFICATION_SEND, getNotificationService(true));
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
|
|
|
|
boolean send_partial = prefs.getBoolean("send_partial", false);
|
|
|
|
boolean reply_move = prefs.getBoolean("reply_move", false);
|
|
|
|
boolean reply_move = prefs.getBoolean("reply_move", false);
|
|
|
|
boolean reply_move_inbox = prefs.getBoolean("reply_move_inbox", true);
|
|
|
|
boolean reply_move_inbox = prefs.getBoolean("reply_move_inbox", true);
|
|
|
|
boolean protocol = prefs.getBoolean("protocol", false);
|
|
|
|
boolean protocol = prefs.getBoolean("protocol", false);
|
|
|
@ -761,8 +762,10 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Create transport
|
|
|
|
// Create transport
|
|
|
|
long start, end;
|
|
|
|
long start = 0;
|
|
|
|
|
|
|
|
long end = 0;
|
|
|
|
Long max_size = null;
|
|
|
|
Long max_size = null;
|
|
|
|
|
|
|
|
SMTPSendFailedException partial = null;
|
|
|
|
if (ident.auth_type == AUTH_TYPE_GRAPH) {
|
|
|
|
if (ident.auth_type == AUTH_TYPE_GRAPH) {
|
|
|
|
start = new Date().getTime();
|
|
|
|
start = new Date().getTime();
|
|
|
|
MicrosoftGraph.send(ServiceSend.this, ident, imessage);
|
|
|
|
MicrosoftGraph.send(ServiceSend.this, ident, imessage);
|
|
|
@ -770,6 +773,8 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
EmailService iservice = new EmailService(this, ident, EmailService.PURPOSE_USE, debug);
|
|
|
|
EmailService iservice = new EmailService(this, ident, EmailService.PURPOSE_USE, debug);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (send_partial)
|
|
|
|
|
|
|
|
iservice.setSendPartial(true);
|
|
|
|
iservice.setUseIp(ident.use_ip, ident.ehlo);
|
|
|
|
iservice.setUseIp(ident.use_ip, ident.ehlo);
|
|
|
|
if (!message.isSigned() && !message.isEncrypted())
|
|
|
|
if (!message.isSigned() && !message.isEncrypted())
|
|
|
|
iservice.set8BitMime(ident.octetmime);
|
|
|
|
iservice.set8BitMime(ident.octetmime);
|
|
|
@ -820,6 +825,12 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
recipients.add(a);
|
|
|
|
recipients.add(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (BuildConfig.DEBUG && false) {
|
|
|
|
|
|
|
|
InternetAddress invalid = new InternetAddress();
|
|
|
|
|
|
|
|
invalid.setAddress("invalid");
|
|
|
|
|
|
|
|
recipients.add(invalid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (protocol && BuildConfig.DEBUG) {
|
|
|
|
if (protocol && BuildConfig.DEBUG) {
|
|
|
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
|
imessage.writeTo(bos);
|
|
|
|
imessage.writeTo(bos);
|
|
|
@ -855,15 +866,27 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
// Send message
|
|
|
|
// Send message
|
|
|
|
EntityLog.log(this, "Sending " + via);
|
|
|
|
EntityLog.log(this, "Sending " + via);
|
|
|
|
start = new Date().getTime();
|
|
|
|
start = new Date().getTime();
|
|
|
|
iservice.getTransport().sendMessage(imessage, rcptto);
|
|
|
|
try {
|
|
|
|
end = new Date().getTime();
|
|
|
|
iservice.getTransport().sendMessage(imessage, rcptto);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
end = new Date().getTime();
|
|
|
|
|
|
|
|
}
|
|
|
|
EntityLog.log(this, "Sent " + via + " elapse=" + (end - start) + " ms");
|
|
|
|
EntityLog.log(this, "Sent " + via + " elapse=" + (end - start) + " ms");
|
|
|
|
} catch (MessagingException ex) {
|
|
|
|
} catch (MessagingException ex) {
|
|
|
|
|
|
|
|
|
|
|
|
iservice.dump(ident.email);
|
|
|
|
iservice.dump(ident.email);
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
|
|
|
|
if (ex instanceof SMTPSendFailedException) {
|
|
|
|
if (ex instanceof SMTPSendFailedException) {
|
|
|
|
SMTPSendFailedException sem = (SMTPSendFailedException) ex;
|
|
|
|
SMTPSendFailedException sem = (SMTPSendFailedException) ex;
|
|
|
|
|
|
|
|
if (send_partial &&
|
|
|
|
|
|
|
|
sem.getInvalidAddresses() != null &&
|
|
|
|
|
|
|
|
sem.getValidSentAddresses() != null &&
|
|
|
|
|
|
|
|
sem.getValidUnsentAddresses() != null &&
|
|
|
|
|
|
|
|
sem.getValidSentAddresses().length > 0 &&
|
|
|
|
|
|
|
|
sem.getInvalidAddresses().length + sem.getValidUnsentAddresses().length > 0) {
|
|
|
|
|
|
|
|
partial = sem;
|
|
|
|
|
|
|
|
}
|
|
|
|
ex = new SMTPSendFailedException(
|
|
|
|
ex = new SMTPSendFailedException(
|
|
|
|
sem.getCommand(),
|
|
|
|
sem.getCommand(),
|
|
|
|
sem.getReturnCode(),
|
|
|
|
sem.getReturnCode(),
|
|
|
@ -874,12 +897,13 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
sem.getInvalidAddresses());
|
|
|
|
sem.getInvalidAddresses());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sid != null)
|
|
|
|
if (sid != null && partial == null)
|
|
|
|
db.message().deleteMessage(sid);
|
|
|
|
db.message().deleteMessage(sid);
|
|
|
|
|
|
|
|
|
|
|
|
db.identity().setIdentityError(ident.id, Log.formatThrowable(ex));
|
|
|
|
db.identity().setIdentityError(ident.id, Log.formatThrowable(ex));
|
|
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
if (partial == null)
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
iservice.dump(ident.email);
|
|
|
|
iservice.dump(ident.email);
|
|
|
|
throw ex;
|
|
|
|
throw ex;
|
|
|
@ -898,7 +922,20 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
db.beginTransaction();
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
// Delete from outbox
|
|
|
|
// Delete from outbox
|
|
|
|
db.message().deleteMessage(message.id);
|
|
|
|
if (partial == null)
|
|
|
|
|
|
|
|
db.message().deleteMessage(message.id);
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
Throwable ex = new Throwable(getString(R.string.title_advanced_sent_partially), partial);
|
|
|
|
|
|
|
|
db.message().setMessageWarning(message.id, Log.formatThrowable(ex));
|
|
|
|
|
|
|
|
if (NotificationHelper.areNotificationsEnabled(nm)) {
|
|
|
|
|
|
|
|
NotificationCompat.Builder builder = getNotificationError(
|
|
|
|
|
|
|
|
MessageHelper.formatAddressesShort(message.to),
|
|
|
|
|
|
|
|
ex, 0);
|
|
|
|
|
|
|
|
nm.notify("partial:" + message.id,
|
|
|
|
|
|
|
|
NotificationHelper.NOTIFICATION_TAGGED,
|
|
|
|
|
|
|
|
builder.build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Show in sent folder
|
|
|
|
// Show in sent folder
|
|
|
|
if (sid != null) {
|
|
|
|
if (sid != null) {
|
|
|
@ -907,6 +944,20 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|
|
|
db.attachment().deleteAttachments(sid,
|
|
|
|
db.attachment().deleteAttachments(sid,
|
|
|
|
new int[]{EntityAttachment.PGP_MESSAGE, EntityAttachment.SMIME_MESSAGE});
|
|
|
|
new int[]{EntityAttachment.PGP_MESSAGE, EntityAttachment.SMIME_MESSAGE});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (partial != null) {
|
|
|
|
|
|
|
|
List<Address> unsent = new ArrayList<>();
|
|
|
|
|
|
|
|
if (partial.getInvalidAddresses() != null)
|
|
|
|
|
|
|
|
unsent.addAll(Arrays.asList(partial.getInvalidAddresses()));
|
|
|
|
|
|
|
|
if (partial.getValidUnsentAddresses() != null)
|
|
|
|
|
|
|
|
unsent.addAll(Arrays.asList(partial.getValidUnsentAddresses()));
|
|
|
|
|
|
|
|
db.message().setMessageTo(sid,
|
|
|
|
|
|
|
|
DB.Converters.encodeAddresses(MessageHelper.removeAddresses(message.to, unsent)));
|
|
|
|
|
|
|
|
db.message().setMessageCc(sid,
|
|
|
|
|
|
|
|
DB.Converters.encodeAddresses(MessageHelper.removeAddresses(message.cc, unsent)));
|
|
|
|
|
|
|
|
db.message().setMessageBcc(sid,
|
|
|
|
|
|
|
|
DB.Converters.encodeAddresses(MessageHelper.removeAddresses(message.bcc, unsent)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
db.message().setMessageReceived(sid, start);
|
|
|
|
db.message().setMessageReceived(sid, start);
|
|
|
|
db.message().setMessageSent(sid, end);
|
|
|
|
db.message().setMessageSent(sid, end);
|
|
|
|
db.message().setMessageUiHide(sid, false);
|
|
|
|
db.message().setMessageUiHide(sid, false);
|
|
|
|