*/
#endif
-#define TRUE 1
-#define FALSE 0
-
#define NBITS ((sizeof (int)) * 8)
/*
if (sm_mts == MTS_SMTP)
return smtp_init (client, server, port, watch, verbose,
debug, sasl, saslmech, user, oauth_svc, tls);
- else
- return sendmail_init (client, watch, verbose, debug, sasl,
- saslmech, user);
+
+ return sendmail_init (client, watch, verbose, debug, sasl,
+ saslmech, user);
}
static int
} else {
client = LocalName(1); /* no clientname -> LocalName */
}
- }
- /*
- * Last-ditch check just in case client still isn't set to anything
- */
-
- if (client == NULL || *client == '\0')
- client = "localhost";
+ /*
+ * Last-ditch check just in case client still isn't set to anything
+ */
+ if (client == NULL || *client == '\0')
+ client = "localhost";
+ }
nsc = netsec_init();
client = clientname;
else
client = LocalName(1); /* no clientname -> LocalName */
- }
-
- /*
- * Last-ditch check just in case client still isn't set to anything
- */
- if (client == NULL || *client == '\0')
- client = "localhost";
+ /*
+ * Last-ditch check just in case client still isn't set to anything
+ */
+ if (client == NULL || *client == '\0')
+ client = "localhost";
+ }
nsc = netsec_init();
}
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 {
+ advise (NULL, "SMTP server does not support %s, not sending.\n"
+ "Rebuild message with 7-bit headers, WITHOUT -headerencoding utf-8.",
+ EHLOset ("SMTPUTF8") ? "8BITMIME" : "SMTPUTF8");
+ 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.");
+ 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;
&errstr)) != NULL ; ) {
if (doingEHLO
- && strncmp (buffer, "250", sizeof("250") - 1) == 0
+ && strncmp (buffer, "250", LEN("250")) == 0
&& (buffer[3] == '-' || doingEHLO == 2)
&& buffer[4]) {
if (doingEHLO == 2) {