1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

smtp: Simplify the MAIL command and avoid a duplication of send strings

This avoids the duplication of strings when the optional AUTH and SIZE
parameters are required. It also assists with the modifications that
are part of #4892.

Closes #4903
This commit is contained in:
Steve Holme 2020-02-09 15:50:57 +00:00
parent 02f8de6516
commit 0b8651d48b
No known key found for this signature in database
GPG Key ID: 4059CB85CA7E8F19

View File

@ -584,18 +584,13 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
} }
/* Send the MAIL command */ /* Send the MAIL command */
if(!auth && !size) result = Curl_pp_sendf(&conn->proto.smtpc.pp,
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s%s%s%s%s",
"MAIL FROM:%s", from); from, /* Mandatory */
else if(auth && !size) auth ? " AUTH=" : "", /* Optional (on AUTH support) */
result = Curl_pp_sendf(&conn->proto.smtpc.pp, auth ? auth : "",
"MAIL FROM:%s AUTH=%s", from, auth); size ? " SIZE=" : "", /* Optional (on SIZE support) */
else if(auth && size) size ? size : "");
result = Curl_pp_sendf(&conn->proto.smtpc.pp,
"MAIL FROM:%s AUTH=%s SIZE=%s", from, auth, size);
else
result = Curl_pp_sendf(&conn->proto.smtpc.pp,
"MAIL FROM:%s SIZE=%s", from, size);
free(from); free(from);
free(auth); free(auth);