aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2020-02-09 15:50:57 +0000
committerSteve Holme <steve_holme@hotmail.com>2020-02-09 23:08:47 +0000
commit0b8651d48bb70605ef2b0b6563e5becd09104ea6 (patch)
tree2de751e0bb07a984af2e01e0e350cce8d6f86381 /lib
parent02f8de65165ef161a21ace25da3652e1fb13b99b (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/smtp.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index 764a1b75e..7bcff0ce7 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -584,18 +584,13 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
}
/* Send the MAIL command */
- if(!auth && !size)
- result = Curl_pp_sendf(&conn->proto.smtpc.pp,
- "MAIL FROM:%s", from);
- else if(auth && !size)
- result = Curl_pp_sendf(&conn->proto.smtpc.pp,
- "MAIL FROM:%s AUTH=%s", from, auth);
- else if(auth && 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);
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp,
+ "MAIL FROM:%s%s%s%s%s",
+ from, /* Mandatory */
+ auth ? " AUTH=" : "", /* Optional (on AUTH support) */
+ auth ? auth : "",
+ size ? " SIZE=" : "", /* Optional (on SIZE support) */
+ size ? size : "");
free(from);
free(auth);