"p" (M_FROMPATH, use reverse-path in MAIL FROM:<> command), and "L"
(M_LIMITS, enforce SMTP line limits). I would like to change the format
of the mail defn one more time to make named fields so that it would
be more extensible.
SCCS-mr: usr.sbin/sendmail/src/version.c 139
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.145
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.108
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 3.56
SCCS-vsn: usr.sbin/sendmail/src/version.c 3.287
SCCS-vsn: usr.sbin/sendmail/src/util.c 3.39
SCCS-vsn: usr.sbin/sendmail/src/queue.c 3.67
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 3.49
SCCS-vsn: usr.sbin/sendmail/src/usersmtp.c 3.36
SCCS-vsn: usr.sbin/sendmail/src/headers.c 3.46
SCCS-vsn: usr.sbin/sendmail/src/parseaddr.c 3.72
# include "sendmail.h"
# include <sys/stat.h>
# include "sendmail.h"
# include <sys/stat.h>
-SCCSID(@(#)deliver.c 3.144 %G%);
+SCCSID(@(#)deliver.c 3.145 %G%);
/*
** DELIVER -- Deliver a message to a list of addresses.
/*
** DELIVER -- Deliver a message to a list of addresses.
if (clever)
{
/* send the initial SMTP protocol */
if (clever)
{
/* send the initial SMTP protocol */
- rcode = smtpinit(m, pv, (ADDRESS *) NULL);
+ rcode = smtpinit(m, pv);
int i;
e->e_to = to->q_paddr;
int i;
e->e_to = to->q_paddr;
if (i != EX_OK)
{
markfailure(e, to, i);
if (i != EX_OK)
{
markfailure(e, to, i);
else
{
e->e_to = tobuf + 1;
else
{
e->e_to = tobuf + 1;
- rcode = smtpfinish(m, e);
+ rcode = smtpdata(m, e);
}
/* now close the connection */
}
/* now close the connection */
- rcode = sendoff(e, m, pv, ctladdr, FALSE);
+ rcode = sendoff(e, m, pv, ctladdr);
/*
** Do final status disposal.
/*
** Do final status disposal.
** pvp -- parameter vector to send to it.
** ctladdr -- an address pointer controlling the
** user/groupid etc. of the mailer.
** pvp -- parameter vector to send to it.
** ctladdr -- an address pointer controlling the
** user/groupid etc. of the mailer.
-** crlf -- set if we want CRLF on the end of lines.
**
** Returns:
** exit status of mailer.
**
** Returns:
** exit status of mailer.
-sendoff(e, m, pvp, ctladdr, crlf)
+sendoff(e, m, pvp, ctladdr)
register ENVELOPE *e;
MAILER *m;
char **pvp;
ADDRESS *ctladdr;
register ENVELOPE *e;
MAILER *m;
char **pvp;
ADDRESS *ctladdr;
{
auto FILE *mfile;
auto FILE *rfile;
{
auto FILE *mfile;
auto FILE *rfile;
** Format and send message.
*/
** Format and send message.
*/
- putfromline(mfile, m, crlf);
- (*e->e_puthdr)(mfile, m, e, crlf);
- fprintf(mfile, "\n");
- (*e->e_putbody)(mfile, m, FALSE, e, crlf);
+ putfromline(mfile, m);
+ (*e->e_puthdr)(mfile, m, e);
+ putline("\n", mfile, m);
+ (*e->e_putbody)(mfile, m, e);
(void) fclose(mfile);
i = endmailer(pid, pvp[0]);
(void) fclose(mfile);
i = endmailer(pid, pvp[0]);
** Parameters:
** fp -- the file to output to.
** m -- the mailer describing this entry.
** Parameters:
** fp -- the file to output to.
** m -- the mailer describing this entry.
-** crlf -- set if we want a CRLF at the end of the line.
** outputs some text to fp.
*/
** outputs some text to fp.
*/
-putfromline(fp, m, crlf)
register FILE *fp;
register MAILER *m;
{
register FILE *fp;
register MAILER *m;
{
else
# endif UGLYUUCP
expand("$l\n", buf, &buf[sizeof buf - 1], CurEnv);
else
# endif UGLYUUCP
expand("$l\n", buf, &buf[sizeof buf - 1], CurEnv);
- putline(buf, fp, crlf, bitset(M_FULLSMTP, m->m_flags));
}
\f/*
** PUTBODY -- put the body of a message.
**
** Parameters:
** fp -- file to output onto.
}
\f/*
** PUTBODY -- put the body of a message.
**
** Parameters:
** fp -- file to output onto.
-** m -- a mailer descriptor.
-** xdot -- if set, use SMTP hidden dot algorithm.
+** m -- a mailer descriptor to control output format.
** e -- the envelope to put out.
**
** Returns:
** e -- the envelope to put out.
**
** Returns:
** The message is written onto fp.
*/
** The message is written onto fp.
*/
-putbody(fp, m, xdot, e, crlf)
- char buf[MAXLINE + 1];
- bool fullsmtp = bitset(M_FULLSMTP, m->m_flags);
/*
** Output the body of the message
/*
** Output the body of the message
syserr("Cannot open %s", e->e_df);
}
else
syserr("Cannot open %s", e->e_df);
}
else
- putline("<<< No Message Collected >>>", fp, crlf, fullsmtp);
+ putline("<<< No Message Collected >>>", fp, m);
}
if (e->e_dfp != NULL)
{
rewind(e->e_dfp);
}
if (e->e_dfp != NULL)
{
rewind(e->e_dfp);
- buf[0] = '.';
- while (!ferror(fp) &&
- fgets(&buf[1], sizeof buf - 1, e->e_dfp) != NULL)
- {
- putline((xdot && buf[1] == '.') ? buf : &buf[1], fp, crlf, fullsmtp);
- }
+ while (!ferror(fp) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
+ putline(buf, fp, m);
if (f == NULL)
exit(EX_CANTCREAT);
if (f == NULL)
exit(EX_CANTCREAT);
- putfromline(f, ProgMailer, FALSE);
- (*CurEnv->e_puthdr)(f, ProgMailer, CurEnv, FALSE);
- fputs("\n", f);
- (*CurEnv->e_putbody)(f, ProgMailer, FALSE, CurEnv, FALSE);
- fputs("\n", f);
+ putfromline(f, ProgMailer);
+ (*CurEnv->e_puthdr)(f, ProgMailer, CurEnv);
+ putline("\n", f, ProgMailer);
+ (*CurEnv->e_putbody)(f, ProgMailer, CurEnv);
+ putline("\n", f, ProgMailer);
(void) fclose(f);
(void) fflush(stdout);
(void) fclose(f);
(void) fflush(stdout);
# include <errno.h>
# include "sendmail.h"
# include <errno.h>
# include "sendmail.h"
-SCCSID(@(#)headers.c 3.45 %G%);
+SCCSID(@(#)headers.c 3.46 %G%);
/*
** CHOMPHEADER -- process and save a header line.
/*
** CHOMPHEADER -- process and save a header line.
** fp -- file to put it on.
** m -- mailer to use.
** e -- envelope to use.
** fp -- file to put it on.
** m -- mailer to use.
** e -- envelope to use.
-** crlf -- if set, output CRLF on the end of lines.
-putheader(fp, m, e, crlf)
register FILE *fp;
register MAILER *m;
register ENVELOPE *e;
register FILE *fp;
register MAILER *m;
register ENVELOPE *e;
extern char *arpadate();
extern char *capitalize();
char obuf[MAXLINE];
extern char *arpadate();
extern char *capitalize();
char obuf[MAXLINE];
- bool fullsmtp = bitset(M_FULLSMTP, m->m_flags);
for (h = e->e_header; h != NULL; h = h->h_link)
{
for (h = e->e_header; h != NULL; h = h->h_link)
{
if (bitset(H_FROM, h->h_flags))
oldstyle = FALSE;
if (bitset(H_FROM, h->h_flags))
oldstyle = FALSE;
- commaize(h, p, fp, oldstyle, m, crlf);
+ commaize(h, p, fp, oldstyle, m);
}
else
{
/* vanilla header line */
(void) sprintf(obuf, "%s: %s\n", capitalize(h->h_field), p);
}
else
{
/* vanilla header line */
(void) sprintf(obuf, "%s: %s\n", capitalize(h->h_field), p);
- putline(obuf, fp, crlf, fullsmtp);
** oldstyle -- TRUE if this is an old style header.
** m -- a pointer to the mailer descriptor. If NULL,
** don't transform the name at all.
** oldstyle -- TRUE if this is an old style header.
** m -- a pointer to the mailer descriptor. If NULL,
** don't transform the name at all.
-** crlf -- set if we want CRLF's on the end of lines.
** outputs "p" to file "fp".
*/
** outputs "p" to file "fp".
*/
-commaize(h, p, fp, oldstyle, m, crlf)
+commaize(h, p, fp, oldstyle, m)
register HDR *h;
register char *p;
FILE *fp;
bool oldstyle;
register MAILER *m;
register HDR *h;
register char *p;
FILE *fp;
bool oldstyle;
register MAILER *m;
{
register char *obp;
int opos;
{
register char *obp;
int opos;
bool firstone = TRUE;
char obuf[MAXLINE];
bool firstone = TRUE;
char obuf[MAXLINE];
printf("commaize(%s: %s)\n", h->h_field, p);
# endif DEBUG
printf("commaize(%s: %s)\n", h->h_field, p);
# endif DEBUG
- if (m != NULL && bitset(M_FULLSMTP, m->m_flags))
- fullsmtp = TRUE;
-
obp = obuf;
(void) sprintf(obp, "%s: ", capitalize(h->h_field));
opos = strlen(h->h_field) + 2;
obp = obuf;
(void) sprintf(obp, "%s: ", capitalize(h->h_field));
opos = strlen(h->h_field) + 2;
*p = '\0';
/* translate the name to be relative */
*p = '\0';
/* translate the name to be relative */
- if (m != NULL)
- name = remotename(name, m, bitset(H_FROM, h->h_flags));
+ name = remotename(name, m, bitset(H_FROM, h->h_flags));
if (*name == '\0')
{
*p = savechar;
if (*name == '\0')
{
*p = savechar;
opos += 2;
if (opos > 78 && !firstone)
{
opos += 2;
if (opos > 78 && !firstone)
{
- *obp = '\0';
- putline(obuf, fp, crlf, fullsmtp);
- fputc(',', fp);
- if (crlf)
- fputc('\r', fp);
- fputc('\n', fp);
+ (void) strcat(obp, ",\n");
+ putline(obuf, fp, m);
obp = obuf;
(void) sprintf(obp, " ");
opos = strlen(obp);
obp = obuf;
(void) sprintf(obp, " ");
opos = strlen(obp);
*p = savechar;
}
(void) strcpy(obp, "\n");
*p = savechar;
}
(void) strcpy(obp, "\n");
- putline(obuf, fp, crlf, fullsmtp);
}
\f/*
** ISATWORD -- tell if the word we are pointing to is "at".
}
\f/*
** ISATWORD -- tell if the word we are pointing to is "at".
-SCCSID(@(#)parseaddr.c 3.71 %G%);
+SCCSID(@(#)parseaddr.c 3.72 %G%);
/*
** PARSEADDR -- Parse an address
/*
** PARSEADDR -- Parse an address
printf("remotename(%s)\n", name);
# endif DEBUG
printf("remotename(%s)\n", name);
# endif DEBUG
+ /* don't do anything if we are tagging it as special */
+ if ((senderaddress ? m->m_s_rwset : m->m_r_rwset) < 0)
+ return (name);
+
/*
** Do a heuristic crack of this name to extract any comment info.
** This will leave the name as a comment and a $g macro.
/*
** Do a heuristic crack of this name to extract any comment info.
** This will leave the name as a comment and a $g macro.
# include <errno.h>
# ifndef QUEUE
# include <errno.h>
# ifndef QUEUE
-SCCSID(@(#)queue.c 3.66 %G% (no queueing));
+SCCSID(@(#)queue.c 3.67 %G% (no queueing));
-SCCSID(@(#)queue.c 3.66 %G%);
+SCCSID(@(#)queue.c 3.67 %G%);
register FILE *tfp;
register HDR *h;
register ADDRESS *q;
register FILE *tfp;
register HDR *h;
register ADDRESS *q;
/*
** Create control file.
/*
** Create control file.
return;
}
(void) chmod(e->e_df, FileMode);
return;
}
(void) chmod(e->e_df, FileMode);
- (*e->e_putbody)(dfp, ProgMailer, FALSE, e, FALSE);
+ (*e->e_putbody)(dfp, ProgMailer, e);
(void) fclose(dfp);
e->e_putbody = putbody;
}
(void) fclose(dfp);
e->e_putbody = putbody;
}
** everything as absolute headers.
** All headers that must be relative to the recipient
** can be cracked later.
** everything as absolute headers.
** All headers that must be relative to the recipient
** can be cracked later.
+ ** We set up a "null mailer" -- i.e., a mailer that will have
+ ** no effect on the addresses as they are output.
+ bzero(&nullmailer, sizeof nullmailer);
+ nullmailer.m_r_rwset = nullmailer.m_s_rwset = -1;
+
define('g', "$f", e);
for (h = e->e_header; h != NULL; h = h->h_link)
{
define('g', "$f", e);
for (h = e->e_header; h != NULL; h = h->h_link)
{
else if (bitset(H_FROM|H_RCPT, h->h_flags))
{
commaize(h, h->h_value, tfp, bitset(EF_OLDSTYLE, e->e_flags),
else if (bitset(H_FROM|H_RCPT, h->h_flags))
{
commaize(h, h->h_value, tfp, bitset(EF_OLDSTYLE, e->e_flags),
- (MAILER *) NULL, FALSE);
}
else
fprintf(tfp, "%s: %s\n", h->h_field, h->h_value);
}
else
fprintf(tfp, "%s: %s\n", h->h_field, h->h_value);
-SCCSID(@(#)readcf.c 3.48 %G%);
+SCCSID(@(#)readcf.c 3.49 %G%);
/*
** READCF -- read control file.
/*
** READCF -- read control file.
};
struct optlist OptList[] =
{
};
struct optlist OptList[] =
{
+ 'A', M_ARPAFMT,
+ 'C', M_CANONICAL,
+ 'D', M_NEEDDATE,
+ 'e', M_EXPENSIVE,
+ 'F', M_NEEDFROM,
+ 'h', M_HST_UPPER,
+ 'I', M_INTERNAL,
+ 'L', M_LIMITS,
+ 'l', M_LOCAL,
+ 'M', M_MSGID,
+ 'm', M_MUSER,
+ 'n', M_NHDR,
+ 'p', M_FROMPATH,
+ 'R', M_CRLF,
+ 'r', M_ROPT,
- 'n', M_NHDR,
- 'l', M_LOCAL,
- 'm', M_MUSER,
- 'F', M_NEEDFROM,
- 'D', M_NEEDDATE,
- 'M', M_MSGID,
- 'A', M_ARPAFMT,
- 'U', M_UGLYUUCP,
- 'e', M_EXPENSIVE,
- 'X', M_FULLSMTP,
- 'C', M_CANONICAL,
- 'I', M_INTERNAL,
# include <pwd.h>
# include "sendmail.h"
# include <pwd.h>
# include "sendmail.h"
-SCCSID(@(#)savemail.c 3.55 %G%);
+SCCSID(@(#)savemail.c 3.56 %G%);
/*
** SAVEMAIL -- Save mail on error
/*
** SAVEMAIL -- Save mail on error
** original offending message.
**
** Parameters:
** original offending message.
**
** Parameters:
-** xfile -- the transcript file.
** fp -- the output file.
** fp -- the output file.
-** xdot -- if set, use the SMTP hidden dot algorithm.
+** m -- the mailer to output to.
** e -- the envelope we are working in.
** e -- the envelope we are working in.
-** crlf -- set if we want CRLF's at the end of lines.
** Outputs the body of an error message.
*/
** Outputs the body of an error message.
*/
-errbody(fp, m, xdot, e, crlf)
register FILE *fp;
register struct mailer *m;
register FILE *fp;
register struct mailer *m;
{
register FILE *xfile;
char buf[MAXLINE];
{
register FILE *xfile;
char buf[MAXLINE];
- bool fullsmtp = bitset(M_FULLSMTP, m->m_flags);
if (e->e_xfp != NULL)
(void) fflush(e->e_xfp);
while (fgets(buf, sizeof buf, xfile) != NULL)
if (e->e_xfp != NULL)
(void) fflush(e->e_xfp);
while (fgets(buf, sizeof buf, xfile) != NULL)
- putline(buf, fp, crlf, fullsmtp);
(void) fclose(xfile);
}
errno = 0;
(void) fclose(xfile);
}
errno = 0;
- fprintf(fp, "\n ----- Unsent message follows -----\n");
+ putline("\n", fp, m);
+ putline(" ----- Unsent message follows -----\n", fp, m);
- putheader(fp, m, e->e_parent, crlf);
- fprintf(fp, "\n");
- putbody(fp, m, xdot, e->e_parent, crlf);
+ putheader(fp, m, e->e_parent);
+ putline("\n", fp, m);
+ putbody(fp, m, e->e_parent);
- fprintf(fp, "\n ----- Message header follows -----\n");
+ putline("\n", fp, m);
+ putline(" ----- Message header follows -----\n", fp, m);
- putheader(fp, m, e->e_parent, crlf);
+ putheader(fp, m, e->e_parent);
- fprintf(fp, "\n ----- No message was collected -----\n\n");
+ {
+ putline("\n", fp, m);
+ putline(" ----- No message was collected -----\n", fp, m);
+ putline("\n", fp, m);
+ }
# ifdef _DEFINE
# define EXTERN
# ifndef lint
# ifdef _DEFINE
# define EXTERN
# ifndef lint
-static char SmailSccsId[] = "@(#)sendmail.h 3.107 %G%";
+static char SmailSccsId[] = "@(#)sendmail.h 3.108 %G%";
# endif lint
# else _DEFINE
# define EXTERN extern
# endif lint
# else _DEFINE
# define EXTERN extern
# define M_FULLNAME 000040000L /* want Full-Name field */
# define M_UGLYUUCP 000100000L /* this wants an ugly UUCP from line */
# define M_EXPENSIVE 000200000L /* it costs to use this mailer.... */
# define M_FULLNAME 000040000L /* want Full-Name field */
# define M_UGLYUUCP 000100000L /* this wants an ugly UUCP from line */
# define M_EXPENSIVE 000200000L /* it costs to use this mailer.... */
-# define M_FULLSMTP 000400000L /* must run full SMTP, inc. limits */
+# define M_LIMITS 000400000L /* must enforce SMTP line limits */
# define M_INTERNAL 001000000L /* SMTP to another sendmail site */
# define M_CRLF 002000000L /* use CRLF instead of NL as EOLine */
# define M_INTERNAL 001000000L /* SMTP to another sendmail site */
# define M_CRLF 002000000L /* use CRLF instead of NL as EOLine */
+# define M_FROMPATH 004000000L /* use reverse-path in MAIL FROM: */
+# define M_XDOT 010000000L /* use hidden-dot algorithm */
# define M_ARPAFMT (M_NEEDDATE|M_NEEDFROM|M_MSGID)
# define M_ARPAFMT (M_NEEDDATE|M_NEEDFROM|M_MSGID)
# include "sendmail.h"
# ifndef SMTP
# include "sendmail.h"
# ifndef SMTP
-SCCSID(@(#)usersmtp.c 3.35 %G% (no SMTP));
+SCCSID(@(#)usersmtp.c 3.36 %G% (no SMTP));
-SCCSID(@(#)usersmtp.c 3.35 %G%);
+SCCSID(@(#)usersmtp.c 3.36 %G%);
** m -- mailer to create connection to.
** pvp -- pointer to parameter vector to pass to
** the mailer.
** m -- mailer to create connection to.
** pvp -- pointer to parameter vector to pass to
** the mailer.
-** ctladdr -- controlling address for this mailer.
**
** Returns:
** appropriate exit status -- EX_OK on success.
**
** Returns:
** appropriate exit status -- EX_OK on success.
** creates connection and sends initial protocol.
*/
** creates connection and sends initial protocol.
*/
-smtpinit(m, pvp, ctladdr)
struct mailer *m;
char **pvp;
struct mailer *m;
char **pvp;
{
register int r;
char buf[MAXNAME];
{
register int r;
char buf[MAXNAME];
SmtpIn = SmtpOut = NULL;
SmtpClosing = FALSE;
SmtpIn = SmtpOut = NULL;
SmtpClosing = FALSE;
- SmtpPid = openmailer(m, pvp, ctladdr, TRUE, &SmtpOut, &SmtpIn);
+ SmtpPid = openmailer(m, pvp, (ADDRESS *) NULL, TRUE, &SmtpOut, &SmtpIn);
if (SmtpPid < 0)
{
# ifdef DEBUG
if (SmtpPid < 0)
{
# ifdef DEBUG
** This should appear spontaneously.
*/
** This should appear spontaneously.
*/
if (r < 0 || REPLYTYPE(r) != 2)
return (EX_TEMPFAIL);
if (r < 0 || REPLYTYPE(r) != 2)
return (EX_TEMPFAIL);
** My mother taught me to always introduce myself.
*/
** My mother taught me to always introduce myself.
*/
- smtpmessage("HELO %s", HostName);
- r = reply();
+ smtpmessage("HELO %s", m, HostName);
+ r = reply(m);
if (r < 0)
return (EX_TEMPFAIL);
else if (REPLYTYPE(r) == 5)
if (r < 0)
return (EX_TEMPFAIL);
else if (REPLYTYPE(r) == 5)
if (bitset(M_INTERNAL, m->m_flags))
{
/* tell it to be verbose */
if (bitset(M_INTERNAL, m->m_flags))
{
/* tell it to be verbose */
- smtpmessage("VERB");
- r = reply();
+ smtpmessage("VERB", m);
+ r = reply(m);
if (r < 0)
return (EX_TEMPFAIL);
/* tell it we will be sending one transaction only */
if (r < 0)
return (EX_TEMPFAIL);
/* tell it we will be sending one transaction only */
- smtpmessage("ONEX");
- r = reply();
+ smtpmessage("ONEX", m);
+ r = reply(m);
if (r < 0)
return (EX_TEMPFAIL);
}
if (r < 0)
return (EX_TEMPFAIL);
}
expand("$g", buf, &buf[sizeof buf - 1], CurEnv);
if (CurEnv->e_from.q_mailer == LocalMailer ||
expand("$g", buf, &buf[sizeof buf - 1], CurEnv);
if (CurEnv->e_from.q_mailer == LocalMailer ||
- !bitset(M_FULLSMTP, m->m_flags))
+ !bitset(M_FROMPATH, m->m_flags))
- smtpmessage("MAIL From:<%s>", canonname(buf, 1));
+ smtpmessage("MAIL From:<%s>", m, canonname(buf, 1));
- smtpmessage("MAIL From:<@%s%c%s>", HostName,
- buf[0] == '@' ? ',' : ':', canonname(buf, 1));
+ smtpmessage("MAIL From:<@%s%c%s>", m, HostName,
+ buf[0] == '@' ? ',' : ':', canonname(buf, 1));
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (r == 250)
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (r == 250)
**
** Parameters:
** to -- address of recipient.
**
** Parameters:
** to -- address of recipient.
+** m -- the mailer we are sending to.
**
** Returns:
** exit status corresponding to recipient status.
**
** Returns:
** exit status corresponding to recipient status.
** Sends the mail via SMTP.
*/
** Sends the mail via SMTP.
*/
{
register int r;
extern char *canonname();
{
register int r;
extern char *canonname();
- smtpmessage("RCPT To:<%s>", canonname(to->q_user, 2));
+ smtpmessage("RCPT To:<%s>", m, canonname(to->q_user, 2));
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (REPLYTYPE(r) == 2)
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (REPLYTYPE(r) == 2)
return (EX_PROTOCOL);
}
\f/*
return (EX_PROTOCOL);
}
\f/*
-** SMTPFINISH -- finish up sending all the SMTP protocol.
+** SMTPDATA -- send the data and clean up the transaction.
**
** Parameters:
** m -- mailer being sent to.
**
** Parameters:
** m -- mailer being sent to.
struct mailer *m;
register ENVELOPE *e;
{
struct mailer *m;
register ENVELOPE *e;
{
- ** Dot hiding is done here.
+ ** First send the command and check that it is ok.
+ ** Then send the data.
+ ** Follow it up with a dot to terminate.
+ ** Finally get the results of the transaction.
- smtpmessage("DATA");
- r = reply();
+ /* send the command and check ok to proceed */
+ smtpmessage("DATA", m);
+ r = reply(m);
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (r == 554)
return (EX_UNAVAILABLE);
else if (r != 354)
return (EX_PROTOCOL);
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (r == 554)
return (EX_UNAVAILABLE);
else if (r != 354)
return (EX_PROTOCOL);
- (*e->e_puthdr)(SmtpOut, m, CurEnv, TRUE);
- fprintf(SmtpOut, "\r\n");
- (*e->e_putbody)(SmtpOut, m, TRUE, CurEnv, TRUE);
- smtpmessage(".");
- r = reply();
+
+ /* now output the actual message */
+ (*e->e_puthdr)(SmtpOut, m, CurEnv);
+ putline("\n", SmtpOut, m);
+ (*e->e_putbody)(SmtpOut, m, CurEnv);
+
+ /* terminate the message */
+ fprintf(SmtpOut, ".%s\n", bitset(M_CRLF, m->m_flags) ? "\r" : "");
+ nmessage(Arpa_Info, ">>> .");
+
+ /* check for the results of the transaction */
+ r = reply(m);
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (r == 250)
if (r < 0 || REPLYTYPE(r) == 4)
return (EX_TEMPFAIL);
else if (r == 250)
** sends the final protocol and closes the connection.
*/
** sends the final protocol and closes the connection.
*/
/* send the quit message if not a forced quit */
if (!SmtpClosing)
{
/* send the quit message if not a forced quit */
if (!SmtpClosing)
{
- smtpmessage("QUIT");
- (void) reply();
+ smtpmessage("QUIT", m);
+ (void) reply(m);
if (SmtpClosing)
return;
}
if (SmtpClosing)
return;
}
** REPLY -- read arpanet reply
**
** Parameters:
** REPLY -- read arpanet reply
**
** Parameters:
+** m -- the mailer we are reading the reply from.
**
** Returns:
** reply code it reads.
**
** Returns:
** reply code it reads.
** flushes the mail file.
*/
** flushes the mail file.
*/
{
(void) fflush(SmtpOut);
{
(void) fflush(SmtpOut);
syslog(LOG_ERR, "%s", &MsgBuf[4]);
# endif LOG
SmtpClosing = TRUE;
syslog(LOG_ERR, "%s", &MsgBuf[4]);
# endif LOG
SmtpClosing = TRUE;
- smtpquit("reply error");
+ smtpquit("reply error", m);
return (-1);
}
fixcrlf(SmtpReplyBuffer, TRUE);
return (-1);
}
fixcrlf(SmtpReplyBuffer, TRUE);
if (r == SMTPCLOSING)
{
/* send the quit protocol */
if (r == SMTPCLOSING)
{
/* send the quit protocol */
- smtpquit("SMTP Shutdown");
+ smtpquit("SMTP Shutdown", m);
**
** Parameters:
** f -- format
**
** Parameters:
** f -- format
+** m -- the mailer to control formatting.
** a, b, c -- parameters
**
** Returns:
** a, b, c -- parameters
**
** Returns:
+smtpmessage(f, m, a, b, c)
else if (CurEnv->e_xfp != NULL)
fprintf(CurEnv->e_xfp, ">>> %s\n", buf);
if (!SmtpClosing)
else if (CurEnv->e_xfp != NULL)
fprintf(CurEnv->e_xfp, ">>> %s\n", buf);
if (!SmtpClosing)
- fprintf(SmtpOut, "%s\r\n", buf);
+ fprintf(SmtpOut, "%s%s\n", bitset(M_CRLF, m->m_flags) ? "\r" : "", buf);
# include "sendmail.h"
# include "conf.h"
# include "sendmail.h"
# include "conf.h"
-SCCSID(@(#)util.c 3.38 %G%);
+SCCSID(@(#)util.c 3.39 %G%);
/*
** STRIPQUOTES -- Strip quotes & quote bits from a string.
/*
** STRIPQUOTES -- Strip quotes & quote bits from a string.
** Parameters:
** l -- line to put.
** fp -- file to put it onto.
** Parameters:
** l -- line to put.
** fp -- file to put it onto.
-** crlf -- if set, output Carriage Return/Line Feed on lines
-** instead of newline.
-** fullsmtp -- if set, obey strictest SMTP conventions.
+** m -- the mailer used to control output.
# define SMTPLINELIM 990 /* maximum line length */
# define SMTPLINELIM 990 /* maximum line length */
-putline(l, fp, crlf, fullsmtp)
register char *l;
FILE *fp;
register char *l;
FILE *fp;
- bool crlf;
- bool fullsmtp;
{
register char *p;
char svchar;
{
register char *p;
char svchar;
+ char *crlfstring = "\r\n";
+
+ if (!bitset(M_CRLF, m->m_flags))
+ crlfstring++;
p = &l[strlen(l)];
/* check for line overflow */
p = &l[strlen(l)];
/* check for line overflow */
- while (fullsmtp && (p - l) > SMTPLINELIM)
+ while (bitset(M_LIMITS, m->m_flags) && (p - l) > SMTPLINELIM)
{
register char *q = &l[SMTPLINELIM - 1];
svchar = *q;
*q = '\0';
{
register char *q = &l[SMTPLINELIM - 1];
svchar = *q;
*q = '\0';
+ if (l[0] == '.' && bitset(M_XDOT, m->m_flags))
+ fputc('.', fp);
fputs(l, fp);
fputc('!', fp);
fputs(l, fp);
fputc('!', fp);
- if (crlf)
- fputc('\r', fp);
- fputc('\n', fp);
/* output last part */
svchar = *p;
*p = '\0';
/* output last part */
svchar = *p;
*p = '\0';
+ if (l[0] == '.' && bitset(M_XDOT, m->m_flags))
+ fputc('.', fp);
- if (crlf)
- fputc('\r', fp);
- fputc('\n', fp);
*p = svchar;
l = p;
if (*l == '\n')
*p = svchar;
l = p;
if (*l == '\n')
-static char SccsId[] = "@(#)SendMail version 3.286 of %G%";
+static char SccsId[] = "@(#)SendMail version 3.287 of %G%";
-char Version[] = "3.286 [%G%]";
+char Version[] = "3.287 [%G%]";