From 3f3f6be825da333055a1113c4998691b086f4601 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 31 Dec 2009 21:52:01 +0000 Subject: turned CURLOPT_MAIL_RCPT into a curl_slist list instead to support multiple receivers, and made the command line tool thus support the option specified many times --- lib/smtp.c | 19 +++++++++++++++++-- lib/url.c | 4 ++-- lib/urldata.h | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/smtp.c b/lib/smtp.c index 5dd90298b..0f34c4f9e 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -345,8 +345,23 @@ static CURLcode smtp_state_mail_resp(struct connectdata *conn, } else { /* send RCPT TO */ - result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s", - data->set.str[STRING_MAIL_RCPT]); + struct curl_slist *rcpt; + char *buffer = NULL; + + for(rcpt = data->set.mail_rcpt; rcpt; rcpt=rcpt->next) { + char *add = aprintf("%s%s%s", buffer?buffer:"", buffer?", ":"", + rcpt->data); + if(!add) { + free(buffer); + return CURLE_OUT_OF_MEMORY; + } + buffer = add; + } + + result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s", buffer); + + free(buffer); + if(result) return result; diff --git a/lib/url.c b/lib/url.c index 05055acba..3f2f1cd72 100644 --- a/lib/url.c +++ b/lib/url.c @@ -2314,8 +2314,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, break; case CURLOPT_MAIL_RCPT: - result = setstropt(&data->set.str[STRING_MAIL_RCPT], - va_arg(param, char *)); + /* get a list of mail recipients */ + data->set.mail_rcpt = va_arg(param, struct curl_slist *); break; default: diff --git a/lib/urldata.h b/lib/urldata.h index 6c852e8ad..4bcb5bf6f 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1166,7 +1166,6 @@ enum dupstring { STRING_SOCKS5_GSSAPI_SERVICE, /* GSSAPI service name */ #endif STRING_MAIL_FROM, - STRING_MAIL_RCPT, /* -- end of strings -- */ STRING_LAST /* not used, just an end-of-list marker */ @@ -1337,6 +1336,7 @@ struct UserDefined { #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) long socks5_gssapi_nec; /* flag to support nec socks5 server */ #endif + struct curl_slist *mail_rcpt; /* linked list of mail recipients */ }; struct Names { -- cgit v1.2.3