Fix SMTP RFC violation for better interoperability

Space after colon violates RFC 5321 (and RFC 821): "Since it has been a common
source of errors, it is worth noting that spaces are not permitted on either
side of the colon following FROM in the MAIL command or TO in the RCPT command"

Change-Id: Ie5330bf2bd01cd8f734134dadd742cf16df70d7a
Signed-off-by: Jack Bates <jack@nottheoilrig.com>

cherry-pick of https://android-review.googlesource.com/#/c/32640/
This commit is contained in:
Jack Bates 2012-02-09 16:15:57 +00:00 committed by Paul Westbrook
parent 156163cceb
commit 4fd97a3050
2 changed files with 6 additions and 6 deletions

View File

@ -178,15 +178,15 @@ public class SmtpSender extends Sender {
Address[] bcc = Address.unpack(message.mBcc);
try {
executeSimpleCommand("MAIL FROM: " + "<" + from.getAddress() + ">");
executeSimpleCommand("MAIL FROM:" + "<" + from.getAddress() + ">");
for (Address address : to) {
executeSimpleCommand("RCPT TO: " + "<" + address.getAddress().trim() + ">");
executeSimpleCommand("RCPT TO:" + "<" + address.getAddress().trim() + ">");
}
for (Address address : cc) {
executeSimpleCommand("RCPT TO: " + "<" + address.getAddress().trim() + ">");
executeSimpleCommand("RCPT TO:" + "<" + address.getAddress().trim() + ">");
}
for (Address address : bcc) {
executeSimpleCommand("RCPT TO: " + "<" + address.getAddress().trim() + ">");
executeSimpleCommand("RCPT TO:" + "<" + address.getAddress().trim() + ">");
}
executeSimpleCommand("DATA");
// TODO byte stuffing

View File

@ -174,9 +174,9 @@ public class SmtpSenderUnitTests extends AndroidTestCase {
* Prepare to receive a simple message (see setupSimpleMessage)
*/
private void expectSimpleMessage(MockTransport mockTransport) {
mockTransport.expect("MAIL FROM: <Jones@Registry.Org>",
mockTransport.expect("MAIL FROM:<Jones@Registry.Org>",
"250 2.1.0 <Jones@Registry.Org> sender ok");
mockTransport.expect("RCPT TO: <Smith@Registry.Org>",
mockTransport.expect("RCPT TO:<Smith@Registry.Org>",
"250 2.1.5 <Smith@Registry.Org> recipient ok");
mockTransport.expect("DATA", "354 enter mail, end with . on a line by itself");
mockTransport.expect("Date: .*");