aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-02-20 22:29:59 +0000
committerDaniel Stenberg <daniel@haxx.se>2010-02-20 22:29:59 +0000
commita4a60afabbd65e674222a6df6ccd09c1b358ab77 (patch)
tree82dffbc3278c15912092c662c735972bef8d5dc2 /lib
parenta434cb43e807753730d815096464c9c7cb3f1596 (diff)
- 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.
Diffstat (limited to 'lib')
-rw-r--r--lib/smtp.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index f879651c6..238fc2dbb 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -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 */