1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-14 21:45:14 -05:00
k-9/src/com/android/email/mail/Transport.java
Daniel Applebaum bf98b5c2af Issue 366
Significant hardening of the email sending process.

A given message in the Outbox is only attempted to be sent 5 times.
Once the threshold is reached, the message is flagged.  asses through
the Outbox skip flagged messages.  The message can be tried again by
manually unflagging.  When any messages are flagged during a pass
through the Outbox, K-9 raises a notification with a fast flashing red
LED, alerting the user to the failure to send.  A note is also placed
in the K9mail-errors.

The read timeout on SMTP connections has been changed to 300000ms (5
minutes)

The send attempt counter is kept in memory, not stored with the
message, so a phone or application restart will clear the counters,
but not the flagged state.  As the intent of this revision is to avoid
runaway message sending, this is deemed to be acceptable for now.

The moving of messages from the Outbox to the Sent folder has been
changed to an atomic move.

Extra error checking has been added to the SMTP communication code.

The flashing LED may be excessive.
2009-04-09 17:48:05 +00:00

29 lines
928 B
Java

package com.android.email.mail;
import com.android.email.mail.transport.SmtpTransport;
import com.android.email.mail.transport.WebDavTransport;
public abstract class Transport {
protected static final int SOCKET_CONNECT_TIMEOUT = 10000;
// RFC 1047
protected static final int SOCKET_READ_TIMEOUT = 300000;
public synchronized static Transport getInstance(String uri) throws MessagingException {
if (uri.startsWith("smtp")) {
return new SmtpTransport(uri);
} else if (uri.startsWith("webdav")) {
return new WebDavTransport(uri);
} else {
throw new MessagingException("Unable to locate an applicable Transport for " + uri);
}
}
public abstract void open() throws MessagingException;
public abstract void sendMessage(Message message) throws MessagingException;
public abstract void close() throws MessagingException;
}