From 483edeb8dda80406f56480965d3c649bb3b2e77b Mon Sep 17 00:00:00 2001 From: Steve Holme Date: Thu, 13 Feb 2020 22:39:28 +0000 Subject: smtp: Support the SMTPUTF8 extension in the RCPT TO command Note: The RCPT TO command isn't required to advertise to the server that it contains UTF-8 characters, instead the server is told that a mail may contain UTF-8 in any envelope command via the MAIL command. --- lib/smtp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/smtp.c') diff --git a/lib/smtp.c b/lib/smtp.c index cdeeb7a26..ef51c829a 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -670,6 +670,23 @@ static CURLcode smtp_perform_mail(struct connectdata *conn) } } + /* If the mailboxes in the FROM and AUTH parameters don't include a UTF-8 + based address then quickly scan through the recipient list and check if + any there do, as we need to correctly identify our support for SMTPUTF8 + in the envelope, as per RFC-6531 sect. 3.4 */ + if(conn->proto.smtpc.utf8_supported && !utf8) { + struct SMTP *smtp = data->req.protop; + struct curl_slist *rcpt = smtp->rcpt; + + while(rcpt && !utf8) { + /* Does the host name contain non-ASCII characters? */ + if(!Curl_is_ASCII_name(rcpt->data)) + utf8 = TRUE; + + rcpt = rcpt->next; + } + } + /* Send the MAIL command */ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "MAIL FROM:%s%s%s%s%s%s", @@ -679,7 +696,7 @@ static CURLcode smtp_perform_mail(struct connectdata *conn) size ? " SIZE=" : "", /* Optional on SIZE support */ size ? size : "", /* */ utf8 ? " SMTPUTF8" /* Internationalised mailbox */ - : ""); /* address included */ + : ""); /* included in our envelope */ free(from); free(auth); -- cgit v1.2.1