aboutsummaryrefslogtreecommitdiff
path: root/lib/smtp.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-04-16 19:30:43 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-04-16 19:44:47 +0100
commit8093f9541e1be58399adfd23d80fa8f98dc39966 (patch)
tree314bd61ae39927b3a809f394b8771a8dc1df85d9 /lib/smtp.c
parent68e7fb499d93ffcad8b7407c07689c8a5b1628b2 (diff)
smtp: Moved smtp_mail() to be with the other perform functions
Diffstat (limited to 'lib/smtp.c')
-rw-r--r--lib/smtp.c144
1 files changed, 72 insertions, 72 deletions
diff --git a/lib/smtp.c b/lib/smtp.c
index fd86a95ba..e945b41e1 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -497,6 +497,78 @@ static CURLcode smtp_authenticate(struct connectdata *conn)
return result;
}
+/* Start the DO phase */
+static CURLcode smtp_mail(struct connectdata *conn)
+{
+ char *from = NULL;
+ char *auth = NULL;
+ char *size = NULL;
+ CURLcode result = CURLE_OK;
+ struct SessionHandle *data = conn->data;
+
+ /* Calculate the FROM parameter */
+ if(!data->set.str[STRING_MAIL_FROM])
+ /* Null reverse-path, RFC-2821, sect. 3.7 */
+ from = strdup("<>");
+ else if(data->set.str[STRING_MAIL_FROM][0] == '<')
+ from = aprintf("%s", data->set.str[STRING_MAIL_FROM]);
+ else
+ from = aprintf("<%s>", data->set.str[STRING_MAIL_FROM]);
+
+ if(!from)
+ return CURLE_OUT_OF_MEMORY;
+
+ /* Calculate the optional AUTH parameter */
+ if(data->set.str[STRING_MAIL_AUTH] && conn->proto.smtpc.authused) {
+ if(data->set.str[STRING_MAIL_AUTH][0] != '\0')
+ auth = aprintf("%s", data->set.str[STRING_MAIL_AUTH]);
+ else
+ /* Empty AUTH, RFC-2554, sect. 5 */
+ auth = strdup("<>");
+
+ if(!auth) {
+ Curl_safefree(from);
+
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+
+ /* calculate the optional SIZE parameter */
+ if(conn->proto.smtpc.size_supported && conn->data->set.infilesize > 0) {
+ size = aprintf("%" FORMAT_OFF_T, data->set.infilesize);
+
+ if(!size) {
+ Curl_safefree(from);
+ Curl_safefree(auth);
+
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+
+ /* 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);
+
+ Curl_safefree(from);
+ Curl_safefree(auth);
+ Curl_safefree(size);
+
+ if(!result)
+ state(conn, SMTP_MAIL);
+
+ return result;
+}
+
/* For the initial server greeting */
static CURLcode smtp_state_servergreet_resp(struct connectdata *conn,
int smtpcode,
@@ -934,78 +1006,6 @@ static CURLcode smtp_state_auth_final_resp(struct connectdata *conn,
return result;
}
-/* Start the DO phase */
-static CURLcode smtp_mail(struct connectdata *conn)
-{
- char *from = NULL;
- char *auth = NULL;
- char *size = NULL;
- CURLcode result = CURLE_OK;
- struct SessionHandle *data = conn->data;
-
- /* Calculate the FROM parameter */
- if(!data->set.str[STRING_MAIL_FROM])
- /* Null reverse-path, RFC-2821, sect. 3.7 */
- from = strdup("<>");
- else if(data->set.str[STRING_MAIL_FROM][0] == '<')
- from = aprintf("%s", data->set.str[STRING_MAIL_FROM]);
- else
- from = aprintf("<%s>", data->set.str[STRING_MAIL_FROM]);
-
- if(!from)
- return CURLE_OUT_OF_MEMORY;
-
- /* Calculate the optional AUTH parameter */
- if(data->set.str[STRING_MAIL_AUTH] && conn->proto.smtpc.authused) {
- if(data->set.str[STRING_MAIL_AUTH][0] != '\0')
- auth = aprintf("%s", data->set.str[STRING_MAIL_AUTH]);
- else
- /* Empty AUTH, RFC-2554, sect. 5 */
- auth = strdup("<>");
-
- if(!auth) {
- Curl_safefree(from);
-
- return CURLE_OUT_OF_MEMORY;
- }
- }
-
- /* calculate the optional SIZE parameter */
- if(conn->proto.smtpc.size_supported && conn->data->set.infilesize > 0) {
- size = aprintf("%" FORMAT_OFF_T, data->set.infilesize);
-
- if(!size) {
- Curl_safefree(from);
- Curl_safefree(auth);
-
- return CURLE_OUT_OF_MEMORY;
- }
- }
-
- /* 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);
-
- Curl_safefree(from);
- Curl_safefree(auth);
- Curl_safefree(size);
-
- if(!result)
- state(conn, SMTP_MAIL);
-
- return result;
-}
-
static CURLcode smtp_rcpt_to(struct connectdata *conn)
{
CURLcode result = CURLE_OK;