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.
This commit is contained in:
Steve Holme 2020-02-13 22:39:28 +00:00
parent aba1bf630f
commit 483edeb8dd
No known key found for this signature in database
GPG key ID: 4059CB85CA7E8F19
4 changed files with 91 additions and 6 deletions

View file

@ -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);