From 0a0f3c63a624b719f97147fcc2ff28a9ed643a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ku=C4=8Dera?= Date: Sun, 2 Sep 2012 10:53:27 +0200 Subject: [PATCH] SMTP: only send SIZE if supported SMTP client will send SIZE parameter in MAIL FROM command only if server supports it. Without this patch server might say "504 Command parameter not implemented" and reject the message. Bug: http://curl.haxx.se/bug/view.cgi?id=3564114 --- lib/smtp.c | 7 ++++++- lib/smtp.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/smtp.c b/lib/smtp.c index 81c069f7d..b73bb2d89 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -232,6 +232,11 @@ static int smtp_endofresp(struct pingpong *pp, int *resp) line += 4; len -= 4; + if(smtpc->state == SMTP_EHLO && len >= 4 && !memcmp(line, "SIZE", 4)) { + DEBUGF(infof(conn->data, "Server supports SIZE extension.\n")); + smtpc->size_supported = true; + } + if(smtpc->state == SMTP_EHLO && len >= 5 && !memcmp(line, "AUTH ", 5)) { line += 5; len -= 5; @@ -943,7 +948,7 @@ static CURLcode smtp_mail(struct connectdata *conn) } /* calculate the optional SIZE parameter */ - if(conn->data->set.infilesize > 0) { + if(conn->proto.smtpc.size_supported && conn->data->set.infilesize > 0) { size = aprintf("%" FORMAT_OFF_T, data->set.infilesize); if(!size) { diff --git a/lib/smtp.h b/lib/smtp.h index 38fd1b70a..d68a659b5 100644 --- a/lib/smtp.h +++ b/lib/smtp.h @@ -66,6 +66,8 @@ struct smtp_conn { struct curl_slist *rcpt; /* Recipient list */ bool ssldone; /* Is connect() over SSL done? only relevant in multi mode */ + bool size_supported; /* If server supports SIZE extension according to + RFC 1870 */ }; extern const struct Curl_handler Curl_handler_smtp;