X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/630bc83596ec832c428f9196aa947f595932bbac..07fc0c55b466a5f7f4f4efdc62b9086abd45cfc6:/mts/smtp/smtp.c diff --git a/mts/smtp/smtp.c b/mts/smtp/smtp.c index 782461a0..c94ac313 100644 --- a/mts/smtp/smtp.c +++ b/mts/smtp/smtp.c @@ -149,7 +149,7 @@ smtp_init (char *client, char *server, char *port, int watch, int verbose, netsec_set_snoop(nsc, 1); if (sasl) { - if (netsec_set_sasl_params(nsc, client, "smtp", saslmech, + if (netsec_set_sasl_params(nsc, server, "smtp", saslmech, sm_sasl_callback, &errstr) != OK) return sm_nerror(errstr); } @@ -441,9 +441,36 @@ rclient (char *server, char *service) } int -sm_winit (char *from) +sm_winit (char *from, int smtputf8, int eightbit) { - switch (smtalk (SM_MAIL, "MAIL FROM:<%s>", from)) { + const char *mail_parameters = ""; + + if (smtputf8) { + /* Just for information, if an attempt is made to send to an 8-bit + address without specifying SMTPUTF8, Gmail responds with + 555 5.5.2 Syntax error. + Gmail doesn't require the 8BITMIME, but RFC 6531 Sec. 1.2 does. */ + if (EHLOset ("8BITMIME") && EHLOset ("SMTPUTF8")) { + mail_parameters = " BODY=8BITMIME SMTPUTF8"; + } else { + sm_end (NOTOK); + return RP_UCMD; + } + } else if (eightbit) { + /* Comply with RFC 6152, for messages that have any 8-bit characters + in their body. */ + if (EHLOset ("8BITMIME")) { + mail_parameters = " BODY=8BITMIME"; + } else { + advise (NULL, "SMTP server does not support 8BITMIME, not sending.\n" + "Suggest encoding message for 7-bit transport by setting your\n" + "locale to C, and/or specifying *b64 in mhbuild directives.\n"); + sm_end (NOTOK); + return RP_UCMD; + } + } + + switch (smtalk (SM_MAIL, "MAIL FROM:<%s>%s", from, mail_parameters)) { case 250: sm_addrs = 0; return RP_OK; @@ -1012,7 +1039,7 @@ sm_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, *outdata = NULL; *outdatalen = 0; } else { - rc = decodeBase64(line + 4, (const char **) outdata, &len, 0, NULL); + rc = decodeBase64(line + 4, outdata, &len, 0, NULL); if (rc != OK) { netsec_err(errstr, "Unable to decode base64 response"); return NOTOK;