mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
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
This commit is contained in:
parent
01682cca55
commit
3f3f6be825
19
lib/smtp.c
19
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;
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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 {
|
||||
|
@ -501,7 +501,7 @@ struct Configurable {
|
||||
int proxyver; /* set to CURLPROXY_HTTP* define */
|
||||
char *noproxy;
|
||||
char *mail_from;
|
||||
char *mail_rcpt;
|
||||
struct curl_slist *mail_rcpt;
|
||||
bool proxytunnel;
|
||||
bool ftp_append; /* APPE on ftp */
|
||||
bool mute; /* shutup */
|
||||
@ -2279,7 +2279,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
GetStr(&config->mail_from, nextarg);
|
||||
break;
|
||||
case 'B': /* --mail-rcpt */
|
||||
GetStr(&config->mail_rcpt, nextarg);
|
||||
/* append receiver to a list */
|
||||
err = add2list(&config->mail_rcpt, nextarg);
|
||||
if(err)
|
||||
return err;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -3837,6 +3840,7 @@ static void free_config_fields(struct Configurable *config)
|
||||
curl_slist_free_all(config->postquote);
|
||||
curl_slist_free_all(config->headers);
|
||||
curl_slist_free_all(config->telnet_options);
|
||||
curl_slist_free_all(config->mail_rcpt);
|
||||
|
||||
if(config->easy)
|
||||
curl_easy_cleanup(config->easy);
|
||||
|
Loading…
Reference in New Issue
Block a user