]> granicus.if.org Git - curl/commitdiff
modified to get the EHLO domain from the path part of the URL instead of the
authorDaniel Stenberg <daniel@haxx.se>
Wed, 30 Dec 2009 22:50:42 +0000 (22:50 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 30 Dec 2009 22:50:42 +0000 (22:50 +0000)
user name

lib/smtp.c
lib/smtp.h
tests/data/test802
tests/data/test803

index e95a2576e37282a852d2159c7d1dc4f3a22830a2..5dd90298b85e8d33ef48eda4a68369846d0b76fd 100644 (file)
@@ -248,11 +248,10 @@ static void state(struct connectdata *conn,
 static CURLcode smtp_state_ehlo(struct connectdata *conn)
 {
   CURLcode result;
-  struct FTP *smtp = conn->data->state.proto.smtp;
+  struct smtp_conn *smtpc = &conn->proto.smtpc;
 
   /* send EHLO */
-  result = Curl_pp_sendf(&conn->proto.smtpc.pp, "EHLO %s",
-                         smtp->user?smtp->user:"");
+  result = Curl_pp_sendf(&conn->proto.smtpc.pp, "EHLO %s", smtpc->domain);
   if(result)
     return result;
 
@@ -545,6 +544,8 @@ static CURLcode smtp_connect(struct connectdata *conn,
   struct smtp_conn *smtpc = &conn->proto.smtpc;
   struct SessionHandle *data=conn->data;
   struct pingpong *pp=&smtpc->pp;
+  const char *path = conn->data->state.path;
+  int len;
 
   *done = FALSE; /* default to not done yet */
 
@@ -609,6 +610,12 @@ static CURLcode smtp_connect(struct connectdata *conn,
   pp->endofresp = smtp_endofresp;
   pp->conn = conn;
 
+  if(!*path)
+    path = "localhost";
+
+  /* url decode the path and use it as domain with EHLO */
+  smtpc->domain = curl_easy_unescape(conn->data, path, 0, &len);
+
   /* When we connect, we start in the state where we await the server greeting
    */
   state(conn, SMTP_SERVERGREET);
@@ -801,12 +808,15 @@ static CURLcode smtp_dophase_done(struct connectdata *conn,
 {
   CURLcode result = CURLE_OK;
   struct FTP *smtp = conn->data->state.proto.smtp;
+  struct smtp_conn *smtpc= &conn->proto.smtpc;
   (void)connected;
 
   if(smtp->transfer != FTPTRANSFER_BODY)
     /* no data to transfer */
     result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
 
+  free(smtpc->domain);
+
   return result;
 }
 
index 31de99e231a4380a4680fcb8fd7f3a690849a0b5..a1115e23a1c40f1784ac8294a70670b3ffb48a2c 100644 (file)
@@ -45,9 +45,9 @@ typedef enum {
    struct */
 struct smtp_conn {
   struct pingpong pp;
-  char *domain;      /* what to send in the EHLO */
-  int eob;        /* number of bytes of the EOB (End Of Body) that has been
-                     received thus far */
+  char *domain;    /* what to send in the EHLO */
+  int eob;         /* number of bytes of the EOB (End Of Body) that has been
+                      received thus far */
   smtpstate state; /* always use smtp.c:state() to change state! */
 };
 
index 59d2e8c1ff6c726322dddbd1b3a11da9ae424721..dedc1e1fd9d405261fe34ca610459b2e1564c599 100644 (file)
@@ -26,7 +26,7 @@ To: another
 body
 </stdin>
  <command>
-smtp://%HOSTIP:%SMTPPORT -u user:secret --mail-rcpt 802@foo --mail-from 802@from -T -
+smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 802@foo --mail-from 802@from -T -
 </command>
 </client>
 
index e6e48b5d29c739ffb42b16bccaf7c9e44cb567e8..f445e69cbe26251e0f2742bbe9f36e585f98fbd2 100644 (file)
@@ -32,7 +32,7 @@ To: another
 body
 </stdin>
  <command>
-smtp://%HOSTIP:%SMTPPORT -u user:secret --mail-rcpt 803@foo --mail-from 803@from -T -
+smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 803@foo --mail-from 803@from -T -
 </command>
 </client>