X("server host", 6, SERVSW) /* specify alternate SMTP server */ \
X("snoop", -5, SNOOPSW) /* snoop the SMTP transaction */ \
X("partno", -6, PARTSW) \
- X("queued", -6, QUEUESW) \
X("sasl", SASLminc(-4), SASLSW) \
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
X("saslmech", SASLminc(-5), SASLMECHSW) \
X("user", SASLminc(-4), USERSW) \
- X("port server port name/number", 4, PORTSW) \
+ X("port server submission port name/number", 4, PORTSW) \
X("tls", TLSminc(-3), TLSSW) \
X("initialtls", TLSminc(-10), INITTLSSW) \
X("notls", TLSminc(-5), NTLSSW) \
X("fileproc", -4, FILEPROCSW) \
X("mhlproc", -3, MHLPROCSW) \
+ X("sendmail program", 0, MTSSM) \
X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
X("credentials legacy|file:filename", 0, CREDENTIALSSW) \
X("messageid localname|random", 2, MESSAGEIDSW) \
static int saslssf=-1; /* Our maximum SSF for SASL */
static char *saslmech=NULL; /* Force use of particular SASL mech */
static char *user=NULL; /* Authenticate as this user */
-static char *port="smtp"; /* Name of server port for SMTP */
-static int tls=0; /* Use TLS for encryption */
+static char *port="submission"; /* Name of server port for SMTP submission */
+static int tls=-1; /* Use TLS for encryption */
static int fromcount=0; /* Count of addresses on From: header */
static int seensender=0; /* Have we seen a Sender: header? */
static char *clientsw = NULL;
static char *serversw = NULL;
-extern struct smtp sm_reply;
-
static char prefix[] = "----- =_aaaaaaaaaa";
static char *partno = NULL;
-static int queued = 0;
/*
* static prototypes
FILE *in, *out;
m_getfld_state_t gstate = 0;
-#ifdef LOCALE
- setlocale(LC_ALL, "");
-#endif
- invo_name = r1bindex (argv[0], '/');
-
- /* foil search of user profile/context */
- if (context_foil (NULL) == -1)
- done (1);
+ if (nmh_init(argv[0], 0 /* use context_foil() */)) { return 1; }
mts_init (invo_name);
arguments = getarguments (invo_name, argc, argv, 0);
adios (NULL, "missing argument to %s", argp[-2]);
continue;
- case QUEUESW:
- queued++;
- continue;
-
case SASLSW:
sasl++;
continue;
mhlproc = cp;
continue;
+ case MTSSM:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ sendmail = cp;
+ continue;
+
case MTSSW:
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
if ((out = fopen ("/dev/null", "w")) == NULL)
adios ("/dev/null", "unable to open");
} else {
- char *cp = m_mktemp2(NULL, invo_name, NULL, &out);
- if (cp == NULL) {
- adios ("post", "unable to create temporary file");
- }
+ char *cp = m_mktemp2(NULL, invo_name, NULL, &out);
+ if (cp == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
strncpy(tmpfil, cp, sizeof(tmpfil));
- chmod (tmpfil, 0600);
}
}
envelope = from;
}
+ if (tls == -1) {
+#ifdef TLS_SUPPORT
+ /*
+ * The user didn't specify any of the tls switches. Try to
+ * help them by implying -initialtls if they're using port 465
+ * (smtps, until IANA revoked that registration in 1998).
+ */
+ tls = ! strcmp (port, "465") || ! strcasecmp (port, "smtps")
+ ? 2
+ : 0;
+#else /* ! TLS_SUPPORT */
+ tls = 0;
+#endif /* ! TLS_SUPPORT */
+ }
+
/* If we are doing a "whom" check */
if (whomsw) {
/* This won't work with MTS_SENDMAIL_PIPE. */
post (tmpfil, 0, verbose, envelope);
}
post (bccfil, 1, verbose, envelope);
- unlink (bccfil);
+ (void) m_unlink (bccfil);
} else {
post (tmpfil, 0, isatty (1), envelope);
}
p_refile (tmpfil);
- unlink (tmpfil);
+ (void) m_unlink (tmpfil);
if (verbose) {
if (partno)
if (hdr->flags & HFCC) {
if ((cp = strrchr(str, '\n')))
*cp = 0;
- for (cp = pp = str; (cp = strchr(pp, ',')); pp = cp) {
+ for (pp = str; (cp = strchr(pp, ',')); pp = cp) {
*cp++ = 0;
insert_fcc (hdr, pp);
}
FILE *out;
char *tfile = NULL, *program;
- tfile = m_mktemp2(NULL, "bccs", NULL, &out);
- if (tfile == NULL) adios("bcc", "unable to create temporary file");
+ if ((tfile = m_mktemp2(NULL, "bccs", NULL, &out)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
strncpy (bccfil, tfile, sizeof(bccfil));
fprintf (out, "From: %s\n", fullfrom);
}
} else {
if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch,
- verbose, snoop, queued, sasl,
- saslssf, saslmech, user, tls)) ||
+ verbose, snoop, sasl, saslssf,
+ saslmech, user, tls)) ||
rp_isbad (retval = sm_winit (envelope)))
die (NULL, "problem initializing server; %s", rp_string (retval));
if (!whomsw || checksw)
if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch,
- verbose, snoop, queued, sasl,
- saslssf, saslmech, user, tls))
+ verbose, snoop, sasl, saslssf,
+ saslmech, user, tls))
|| rp_isbad (retval = sm_winit (envelope)))
die (NULL, "problem initializing server; %s", rp_string (retval));
{
NMH_UNUSED (i);
- unlink (tmpfil);
+ (void) m_unlink (tmpfil);
if (msgflags & MINV)
- unlink (bccfil);
+ (void) m_unlink (bccfil);
if (!whomsw || checksw)
sm_end (NOTOK);
{
va_list ap;
- unlink (tmpfil);
+ (void) m_unlink (tmpfil);
if (msgflags & MINV)
- unlink (bccfil);
+ (void) m_unlink (bccfil);
if (!whomsw || checksw)
sm_end (NOTOK);