]> granicus.if.org Git - curl/commitdiff
- Fixed the SMTP compliance by making sure RCPT TO addresses are specified
authorDaniel Stenberg <daniel@haxx.se>
Sat, 20 Feb 2010 22:29:59 +0000 (22:29 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 20 Feb 2010 22:29:59 +0000 (22:29 +0000)
  properly in angle brackets. Recipients provided with CURLOPT_MAIL_RCPT now
  get angle bracket wrapping automatically by libcurl unless the recipient
  starts with an angle bracket as then the app is assumed to deal with that
  properly on its own.

CHANGES
RELEASE-NOTES
docs/libcurl/curl_easy_setopt.3
lib/smtp.c
tests/data/test802
tests/data/test803
tests/ftpserver.pl

diff --git a/CHANGES b/CHANGES
index 28f20475cdd0e516775db51cd81d353174353a5e..99c93dc9ea2516a4ed24b94692f702b9a121b069 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,12 @@
                                   Changelog
 
 Daniel Stenberg (20 Feb 2010)
+- Fixed the SMTP compliance by making sure RCPT TO addresses are specified
+  properly in angle brackets. Recipients provided with CURLOPT_MAIL_RCPT now
+  get angle bracket wrapping automatically by libcurl unless the recipient
+  starts with an angle bracket as then the app is assumed to deal with that
+  properly on its own.
+
 - I made the SMTP code expect a 250 response back from the server after the
   full DATA has been sent, and I modified the test SMTP server to also send
   that response. As usual, the DONE operation that is made after a completed
index 43380c2a01ae959c5def08c0729c309a0757b62a..1d32f380abdccfd3c844b3ee197ae2d1c4f51fa5 100644 (file)
@@ -18,6 +18,7 @@ This release includes the following bugfixes:
  o fixed the CURL_FORMAT_* defines when building with cmake
  o missing quote in libcurl.m4
  o SMTP: now waits for 250 after the DATA transfer
+ o SMTP: use angle brackets in RCPT TO
 
 This release includes the following known bugs:
 
index cbbbefe31283d3a06b9a48024151c359a3efce3a..07c4c0a22169d9c8c3ce951f2757075b869bb8ac 100644 (file)
@@ -1092,6 +1092,10 @@ SMTP mail request.  The linked list should be a fully valid list of \fBstruct
 curl_slist\fP structs properly filled in. Use \fIcurl_slist_append(3)\fP to
 create the list and \fIcurl_slist_free_all(3)\fP to clean up an entire list.
 
+Each recipient in SMTP lingo is specified with angle brackets (<>), but should
+you not use an angle bracket as first letter libcurl will assume you provide a
+single email address only and enclose that with angle brackets for you.
+
 (Added in 7.20.0)
 .SH TFTP OPTIONS
 .IP CURLOPT_TFTP_BLKSIZE
index f879651c6ae5568623164df81619a2885f20cc63..238fc2dbb70fdf9e6b7d098f43381591f1f2faff 100644 (file)
@@ -330,6 +330,25 @@ static CURLcode smtp_mail(struct connectdata *conn)
   return result;
 }
 
+static CURLcode smtp_rcpt_to(struct connectdata *conn)
+{
+  CURLcode result = CURLE_OK;
+  struct smtp_conn *smtpc = &conn->proto.smtpc;
+
+  /* send RCPT TO */
+  if(smtpc->rcpt) {
+    if(smtpc->rcpt->data[0] == '<')
+      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
+                             smtpc->rcpt->data);
+    else
+      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s>",
+                             smtpc->rcpt->data);
+    if(!result)
+      state(conn, SMTP_RCPT);
+  }
+  return result;
+}
+
 /* for MAIL responses */
 static CURLcode smtp_state_mail_resp(struct connectdata *conn,
                                      int smtpcode,
@@ -346,19 +365,11 @@ static CURLcode smtp_state_mail_resp(struct connectdata *conn,
   }
   else {
     struct smtp_conn *smtpc = &conn->proto.smtpc;
-
-    /* send RCPT TO */
     smtpc->rcpt = data->set.mail_rcpt;
 
-    if(smtpc->rcpt) {
-      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
-                             smtpc->rcpt->data);
-      if(result)
-        return result;
-    }
-
-    state(conn, SMTP_RCPT);
+    result = smtp_rcpt_to(conn);
   }
+
   return result;
 }
 
@@ -379,16 +390,13 @@ static CURLcode smtp_state_rcpt_resp(struct connectdata *conn,
   else {
     struct smtp_conn *smtpc = &conn->proto.smtpc;
 
-    /* one RCPT is done, but if there's one more to send go on */
-    smtpc->rcpt = smtpc->rcpt->next;
     if(smtpc->rcpt) {
-      result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
-                             smtpc->rcpt->data);
-      if(result)
-        return result;
+      smtpc->rcpt = smtpc->rcpt->next;
+      result = smtp_rcpt_to(conn);
 
-      state(conn, SMTP_RCPT);
-      return CURLE_OK;
+      /* if we failed or still is in RCPT sending, return */
+      if(result || smtpc->rcpt)
+        return result;
     }
 
     /* send DATA */
@@ -432,8 +440,6 @@ static CURLcode smtp_state_postdata_resp(struct connectdata *conn,
                                      smtpstate instate)
 {
   CURLcode result = CURLE_OK;
-  struct SessionHandle *data = conn->data;
-  struct FTP *smtp = data->state.proto.smtp;
 
   (void)instate; /* no use for this yet */
 
index d3114137d78224c93e5f4557b441f7ebc0c1007e..7027c802dee215a6794c993e0754f6c2e2cbfc30 100644 (file)
@@ -36,8 +36,8 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 802@foo --mail-rcpt 802@foobar.example
 <protocol>
 EHLO user\r
 MAIL FROM:802@from\r
-RCPT TO:802@foo\r
-RCPT TO:802@foobar.example\r
+RCPT TO:<802@foo>\r
+RCPT TO:<802@foobar.example>\r
 DATA\r
 QUIT\r
 </protocol>
index f445e69cbe26251e0f2742bbe9f36e585f98fbd2..24ff0d0011f17d8a08748b37bbe9c447e47a9abf 100644 (file)
@@ -42,7 +42,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 803@foo --mail-from 803@from -T -
 <protocol>
 EHLO user\r
 MAIL FROM:803@from\r
-RCPT TO:803@foo\r
+RCPT TO:<803@foo>\r
 DATA\r
 QUIT\r
 </protocol>
index 8c1692464baad825f6972bb3b2a42c8afd7e37ef..a97af17a4a61187b61c276ec5d5622641649be02 100644 (file)
@@ -482,12 +482,12 @@ sub DATA_smtp {
         return; # failure
     }
 
-    if($testno eq "verifiedserver") {
+    if($testno eq "<verifiedserver>") {
         sendcontrol "554 WE ROOLZ: $$\r\n";
         return 0; # don't wait for data now
     }
     else {
-        $testno =~ s/^([0-9]*).*/$1/;
+        $testno =~ s/^([^0-9]*)([0-9]+).*/$2/;
         sendcontrol "354 Show me the mail\r\n";
     }