smtp_mail: Added support to MAIL FROM for the optional SIZE parameter
The size of the email can now be set via CURLOPT_INFILESIZE. This allows the email to be rejected by the server, if supported, and the maximum size has been configured on the server.
This commit is contained in:
parent
e709cc8627
commit
7f304ab84f
26
lib/smtp.c
26
lib/smtp.c
@ -787,24 +787,36 @@ static CURLcode smtp_state_auth_resp(struct connectdata *conn,
|
|||||||
/* start the DO phase */
|
/* start the DO phase */
|
||||||
static CURLcode smtp_mail(struct connectdata *conn)
|
static CURLcode smtp_mail(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
|
char *from = NULL;
|
||||||
|
char *size = NULL;
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
|
|
||||||
/* send MAIL FROM */
|
/* calculate the FROM parameter */
|
||||||
if(!data->set.str[STRING_MAIL_FROM])
|
if(!data->set.str[STRING_MAIL_FROM])
|
||||||
/* null reverse-path, RFC-2821, sect. 3.7 */
|
/* null reverse-path, RFC-2821, sect. 3.7 */
|
||||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:<>");
|
from = "<>";
|
||||||
|
|
||||||
else if(data->set.str[STRING_MAIL_FROM][0] == '<')
|
else if(data->set.str[STRING_MAIL_FROM][0] == '<')
|
||||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s",
|
from = aprintf("%s", data->set.str[STRING_MAIL_FROM]);
|
||||||
data->set.str[STRING_MAIL_FROM]);
|
|
||||||
else
|
else
|
||||||
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:<%s>",
|
from = aprintf("<%s>", data->set.str[STRING_MAIL_FROM]);
|
||||||
data->set.str[STRING_MAIL_FROM]);
|
|
||||||
|
/* calculate the optional SIZE parameter */
|
||||||
|
if(conn->data->set.infilesize > 0)
|
||||||
|
size = aprintf("%" FORMAT_OFF_T, data->set.infilesize);
|
||||||
|
|
||||||
|
/* send MAIL FROM */
|
||||||
|
if(size == NULL)
|
||||||
|
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s", from);
|
||||||
|
else
|
||||||
|
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s SIZE=%s",
|
||||||
|
from, size);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
state(conn, SMTP_MAIL);
|
state(conn, SMTP_MAIL);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user