/* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */
CINIT(SSL_OPTIONS, LONG, 216),
+ /* set the SMTP auth originator */
+ CINIT(MAIL_AUTH, OBJECTPOINT, 217),
+
CURLOPT_LASTENTRY /* the last unused */
} CURLoption;
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;
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] == '<')
+ auth = aprintf("%s", data->set.str[STRING_MAIL_AUTH]);
+ else
+ auth = aprintf("<%s>", data->set.str[STRING_MAIL_AUTH]);
+
+ if(!auth) {
+ Curl_safefree(from);
+
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+
/* calculate the optional SIZE parameter */
if(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 MAIL FROM */
- if(!size)
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s", from);
+ 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 SIZE=%s", from, size);
- Curl_safefree(size);
Curl_safefree(from);
+ Curl_safefree(auth);
+ Curl_safefree(size);
if(result)
return result;
pp->conn = conn;
if(!*path) {
- if(!Curl_gethostname(localhost, sizeof localhost))
+ if(!Curl_gethostname(localhost, sizeof(localhost)))
path = localhost;
else
path = "localhost";
va_arg(param, char *));
break;
+ case CURLOPT_MAIL_AUTH:
+ result = setstropt(&data->set.str[STRING_MAIL_AUTH],
+ va_arg(param, char *));
+ break;
+
case CURLOPT_MAIL_RCPT:
/* get a list of mail recipients */
data->set.mail_rcpt = va_arg(param, struct curl_slist *);