From 4fd97a305065dfed11adf50612e55b9647ceb236 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Thu, 9 Feb 2012 16:15:57 +0000 Subject: [PATCH] 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 cherry-pick of https://android-review.googlesource.com/#/c/32640/ --- src/com/android/email/mail/transport/SmtpSender.java | 8 ++++---- .../android/email/mail/transport/SmtpSenderUnitTests.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/android/email/mail/transport/SmtpSender.java b/src/com/android/email/mail/transport/SmtpSender.java index b318a59d2..1d7a3d658 100644 --- a/src/com/android/email/mail/transport/SmtpSender.java +++ b/src/com/android/email/mail/transport/SmtpSender.java @@ -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 diff --git a/tests/src/com/android/email/mail/transport/SmtpSenderUnitTests.java b/tests/src/com/android/email/mail/transport/SmtpSenderUnitTests.java index 0f320b6e3..8e9ab750d 100644 --- a/tests/src/com/android/email/mail/transport/SmtpSenderUnitTests.java +++ b/tests/src/com/android/email/mail/transport/SmtpSenderUnitTests.java @@ -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: ", + mockTransport.expect("MAIL FROM:", "250 2.1.0 sender ok"); - mockTransport.expect("RCPT TO: ", + mockTransport.expect("RCPT TO:", "250 2.1.5 recipient ok"); mockTransport.expect("DATA", "354 enter mail, end with . on a line by itself"); mockTransport.expect("Date: .*");