122716Sdist /* 234921Sbostic * Copyright (c) 1983 Eric P. Allman 333731Sbostic * Copyright (c) 1988 Regents of the University of California. 433731Sbostic * All rights reserved. 533731Sbostic * 642831Sbostic * %sccs.include.redist.c% 733731Sbostic */ 822716Sdist 933731Sbostic # include "sendmail.h" 1022716Sdist 1133731Sbostic #ifndef lint 1233731Sbostic #ifdef SMTP 13*58725Seric static char sccsid[] = "@(#)usersmtp.c 6.17 (Berkeley) 03/18/93 (with SMTP)"; 1433731Sbostic #else 15*58725Seric static char sccsid[] = "@(#)usersmtp.c 6.17 (Berkeley) 03/18/93 (without SMTP)"; 1633731Sbostic #endif 1733731Sbostic #endif /* not lint */ 1833731Sbostic 194684Seric # include <sysexits.h> 2021065Seric # include <errno.h> 214684Seric 2233731Sbostic # ifdef SMTP 234684Seric 244684Seric /* 259391Seric ** USERSMTP -- run SMTP protocol from the user end. 269391Seric ** 279391Seric ** This protocol is described in RFC821. 289391Seric */ 299391Seric 309391Seric #define REPLYTYPE(r) ((r) / 100) /* first digit of reply code */ 319391Seric #define REPLYCLASS(r) (((r) / 10) % 10) /* second digit of reply code */ 329391Seric #define SMTPCLOSING 421 /* "Service Shutting Down" */ 339391Seric 3414900Seric char SmtpMsgBuffer[MAXLINE]; /* buffer for commands */ 3510054Seric char SmtpReplyBuffer[MAXLINE]; /* buffer for replies */ 3621065Seric char SmtpError[MAXLINE] = ""; /* save failure error messages */ 3710054Seric int SmtpPid; /* pid of mailer */ 3858671Seric 3958671Seric #ifdef __STDC__ 4058671Seric extern smtpmessage(char *f, MAILER *m, MCI *mci, ...); 4158671Seric #endif 429391Seric /* 434865Seric ** SMTPINIT -- initialize SMTP. 444684Seric ** 454865Seric ** Opens the connection and sends the initial protocol. 464684Seric ** 474684Seric ** Parameters: 484865Seric ** m -- mailer to create connection to. 494865Seric ** pvp -- pointer to parameter vector to pass to 504865Seric ** the mailer. 514684Seric ** 524684Seric ** Returns: 5354967Seric ** none. 544684Seric ** 554684Seric ** Side Effects: 564865Seric ** creates connection and sends initial protocol. 574684Seric */ 584684Seric 5954967Seric smtpinit(m, mci, e) 604865Seric struct mailer *m; 6154967Seric register MCI *mci; 6253751Seric ENVELOPE *e; 634684Seric { 644865Seric register int r; 6514886Seric EVENT *gte; 6652107Seric extern STAB *stab(); 674684Seric 6857379Seric if (tTd(17, 1)) 6957379Seric { 7057379Seric printf("smtpinit "); 7157379Seric mci_dump(mci); 7257379Seric } 7357379Seric 744865Seric /* 754865Seric ** Open the connection to the mailer. 764865Seric */ 774684Seric 7821065Seric SmtpError[0] = '\0'; 7957379Seric CurHostName = mci->mci_host; /* XXX UGLY XXX */ 8054967Seric switch (mci->mci_state) 816051Seric { 8254967Seric case MCIS_ACTIVE: 8354967Seric /* need to clear old information */ 8454967Seric smtprset(m, mci, e); 8557734Seric /* fall through */ 8615139Seric 8754967Seric case MCIS_OPEN: 8854967Seric return; 8954967Seric 9054967Seric case MCIS_ERROR: 9154967Seric case MCIS_SSD: 9254967Seric /* shouldn't happen */ 9354967Seric smtpquit(m, mci, e); 9457734Seric /* fall through */ 9554967Seric 9654967Seric case MCIS_CLOSED: 9758151Seric syserr("451 smtpinit: state CLOSED"); 9854967Seric return; 9954967Seric 10054967Seric case MCIS_OPENING: 10154967Seric break; 1026051Seric } 1034796Seric 10457379Seric SmtpPhase = mci->mci_phase = "user open"; 10554967Seric mci->mci_state = MCIS_OPENING; 10654967Seric 1074865Seric /* 1084865Seric ** Get the greeting message. 10914913Seric ** This should appear spontaneously. Give it five minutes to 11014886Seric ** happen. 1114865Seric */ 1124797Seric 11357379Seric SmtpPhase = mci->mci_phase = "greeting wait"; 11453751Seric setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 11558112Seric r = reply(m, mci, e, TimeOuts.to_initial); 1168005Seric if (r < 0 || REPLYTYPE(r) != 2) 11752104Seric goto tempfail1; 1184684Seric 1194865Seric /* 1204976Seric ** Send the HELO command. 1217963Seric ** My mother taught me to always introduce myself. 1224976Seric */ 1234976Seric 12453751Seric smtpmessage("HELO %s", m, mci, MyHostName); 12557379Seric SmtpPhase = mci->mci_phase = "HELO wait"; 12653751Seric setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 12758112Seric r = reply(m, mci, e, TimeOuts.to_helo); 1288005Seric if (r < 0) 12952104Seric goto tempfail1; 1308005Seric else if (REPLYTYPE(r) == 5) 13114913Seric goto unavailable; 1327963Seric else if (REPLYTYPE(r) != 2) 13352104Seric goto tempfail1; 1344976Seric 1354976Seric /* 1369315Seric ** If this is expected to be another sendmail, send some internal 1379315Seric ** commands. 1389315Seric */ 1399315Seric 14010688Seric if (bitnset(M_INTERNAL, m->m_flags)) 1419315Seric { 1429315Seric /* tell it to be verbose */ 14353751Seric smtpmessage("VERB", m, mci); 14458112Seric r = reply(m, mci, e, TimeOuts.to_miscshort); 1459315Seric if (r < 0) 14652104Seric goto tempfail2; 1479315Seric } 1489315Seric 14953751Seric mci->mci_state = MCIS_OPEN; 15054967Seric return; 15153751Seric 15253751Seric tempfail1: 15353751Seric tempfail2: 15453751Seric mci->mci_exitstat = EX_TEMPFAIL; 15557379Seric if (mci->mci_errno == 0) 15657379Seric mci->mci_errno = errno; 15757379Seric if (mci->mci_state != MCIS_CLOSED) 15857379Seric smtpquit(m, mci, e); 15954967Seric return; 16053751Seric 16153751Seric unavailable: 16253751Seric mci->mci_exitstat = EX_UNAVAILABLE; 16353751Seric mci->mci_errno = errno; 16453751Seric smtpquit(m, mci, e); 16554967Seric return; 16653751Seric } 16753751Seric 16853751Seric smtpmailfrom(m, mci, e) 16953751Seric struct mailer *m; 17054967Seric MCI *mci; 17153751Seric ENVELOPE *e; 17253751Seric { 17353751Seric int r; 17453751Seric char buf[MAXNAME]; 17553751Seric 17657943Seric if (tTd(17, 2)) 17757943Seric printf("smtpmailfrom: CurHost=%s\n", CurHostName); 17857943Seric 1799315Seric /* 1804865Seric ** Send the MAIL command. 1814865Seric ** Designates the sender. 1824865Seric */ 1834796Seric 18453751Seric mci->mci_state = MCIS_ACTIVE; 18553751Seric 18658680Seric if (bitset(EF_RESPONSE, e->e_flags)) 18758680Seric (void) strcpy(buf, ""); 18858680Seric else 18958680Seric expand("\201g", buf, &buf[sizeof buf - 1], e); 19053751Seric if (e->e_from.q_mailer == LocalMailer || 19110688Seric !bitnset(M_FROMPATH, m->m_flags)) 1928436Seric { 19353751Seric smtpmessage("MAIL From:<%s>", m, mci, buf); 1948436Seric } 1958436Seric else 1968436Seric { 19753751Seric smtpmessage("MAIL From:<@%s%c%s>", m, mci, MyHostName, 19810308Seric buf[0] == '@' ? ',' : ':', buf); 1998436Seric } 20057379Seric SmtpPhase = mci->mci_phase = "MAIL wait"; 20153751Seric setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 20258112Seric r = reply(m, mci, e, TimeOuts.to_mail); 2038005Seric if (r < 0 || REPLYTYPE(r) == 4) 20453751Seric { 20553751Seric mci->mci_exitstat = EX_TEMPFAIL; 20653751Seric mci->mci_errno = errno; 20753751Seric smtpquit(m, mci, e); 20853751Seric return EX_TEMPFAIL; 20953751Seric } 2107963Seric else if (r == 250) 21153751Seric { 21253751Seric mci->mci_exitstat = EX_OK; 21353751Seric return EX_OK; 21453751Seric } 2157963Seric else if (r == 552) 21653751Seric { 21753751Seric /* signal service unavailable */ 21853751Seric mci->mci_exitstat = EX_UNAVAILABLE; 21953751Seric smtpquit(m, mci, e); 22053751Seric return EX_UNAVAILABLE; 22153751Seric } 22214913Seric 22358008Seric #ifdef LOG 22458020Seric if (LogLevel > 1) 22558008Seric { 22658008Seric syslog(LOG_CRIT, "%s: SMTP MAIL protocol error: %s", 22758008Seric e->e_id, SmtpReplyBuffer); 22858008Seric } 22958008Seric #endif 23058008Seric 23114913Seric /* protocol error -- close up */ 23253751Seric smtpquit(m, mci, e); 23353751Seric mci->mci_exitstat = EX_PROTOCOL; 23453751Seric return EX_PROTOCOL; 2354684Seric } 2364684Seric /* 2374976Seric ** SMTPRCPT -- designate recipient. 2384797Seric ** 2394797Seric ** Parameters: 2404865Seric ** to -- address of recipient. 24110175Seric ** m -- the mailer we are sending to. 24257379Seric ** mci -- the connection info for this transaction. 24357379Seric ** e -- the envelope for this transaction. 2444797Seric ** 2454797Seric ** Returns: 2464865Seric ** exit status corresponding to recipient status. 2474797Seric ** 2484797Seric ** Side Effects: 2494865Seric ** Sends the mail via SMTP. 2504797Seric */ 2514797Seric 25253751Seric smtprcpt(to, m, mci, e) 2534865Seric ADDRESS *to; 25410175Seric register MAILER *m; 25554967Seric MCI *mci; 25653751Seric ENVELOPE *e; 2574797Seric { 2584797Seric register int r; 2594797Seric 26053751Seric smtpmessage("RCPT To:<%s>", m, mci, to->q_user); 2614865Seric 26257379Seric SmtpPhase = mci->mci_phase = "RCPT wait"; 26353751Seric setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 26458112Seric r = reply(m, mci, e, TimeOuts.to_rcpt); 2658005Seric if (r < 0 || REPLYTYPE(r) == 4) 2664865Seric return (EX_TEMPFAIL); 2677963Seric else if (REPLYTYPE(r) == 2) 2687963Seric return (EX_OK); 2697964Seric else if (r == 550 || r == 551 || r == 553) 2707964Seric return (EX_NOUSER); 2717964Seric else if (r == 552 || r == 554) 2727964Seric return (EX_UNAVAILABLE); 27358008Seric 27458008Seric #ifdef LOG 27558020Seric if (LogLevel > 1) 27658008Seric { 27758008Seric syslog(LOG_CRIT, "%s: SMTP RCPT protocol error: %s", 27858008Seric e->e_id, SmtpReplyBuffer); 27958008Seric } 28058008Seric #endif 28158008Seric 2827964Seric return (EX_PROTOCOL); 2834797Seric } 2844797Seric /* 28510175Seric ** SMTPDATA -- send the data and clean up the transaction. 2864684Seric ** 2874684Seric ** Parameters: 2884865Seric ** m -- mailer being sent to. 2896980Seric ** e -- the envelope for this message. 2904684Seric ** 2914684Seric ** Returns: 2924976Seric ** exit status corresponding to DATA command. 2934684Seric ** 2944684Seric ** Side Effects: 2954865Seric ** none. 2964684Seric */ 2974684Seric 29853740Seric smtpdata(m, mci, e) 2994865Seric struct mailer *m; 30054967Seric register MCI *mci; 3016980Seric register ENVELOPE *e; 3024684Seric { 3034684Seric register int r; 3044684Seric 3054797Seric /* 3064797Seric ** Send the data. 30710175Seric ** First send the command and check that it is ok. 30810175Seric ** Then send the data. 30910175Seric ** Follow it up with a dot to terminate. 31010175Seric ** Finally get the results of the transaction. 3114797Seric */ 3124797Seric 31310175Seric /* send the command and check ok to proceed */ 31453751Seric smtpmessage("DATA", m, mci); 31557379Seric SmtpPhase = mci->mci_phase = "DATA wait"; 31653751Seric setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 31758112Seric r = reply(m, mci, e, TimeOuts.to_datainit); 3188005Seric if (r < 0 || REPLYTYPE(r) == 4) 31957990Seric { 32057990Seric smtpquit(m, mci, e); 3214797Seric return (EX_TEMPFAIL); 32257990Seric } 3237963Seric else if (r == 554) 32457990Seric { 32557990Seric smtprset(m, mci, e); 3267963Seric return (EX_UNAVAILABLE); 32757990Seric } 3287963Seric else if (r != 354) 32957990Seric { 33058008Seric #ifdef LOG 33158020Seric if (LogLevel > 1) 33258008Seric { 33358008Seric syslog(LOG_CRIT, "%s: SMTP DATA-1 protocol error: %s", 33458008Seric e->e_id, SmtpReplyBuffer); 33558008Seric } 33658008Seric #endif 33757990Seric smtprset(m, mci, e); 3387964Seric return (EX_PROTOCOL); 33957990Seric } 34010175Seric 34110175Seric /* now output the actual message */ 34253751Seric (*e->e_puthdr)(mci->mci_out, m, e); 34353740Seric putline("\n", mci->mci_out, m); 34453751Seric (*e->e_putbody)(mci->mci_out, m, e); 34510175Seric 34610175Seric /* terminate the message */ 34753740Seric fprintf(mci->mci_out, ".%s", m->m_eol); 34858120Seric if (Verbose) 34958151Seric nmessage(">>> ."); 35010175Seric 35110175Seric /* check for the results of the transaction */ 35257379Seric SmtpPhase = mci->mci_phase = "result wait"; 35353751Seric setproctitle("%s %s: %s", e->e_id, CurHostName, mci->mci_phase); 35458112Seric r = reply(m, mci, e, TimeOuts.to_datafinal); 35553751Seric if (r < 0) 35657990Seric { 35757990Seric smtpquit(m, mci, e); 3584797Seric return (EX_TEMPFAIL); 35957990Seric } 36053751Seric mci->mci_state = MCIS_OPEN; 36153751Seric if (REPLYTYPE(r) == 4) 36253751Seric return (EX_TEMPFAIL); 3637963Seric else if (r == 250) 3647963Seric return (EX_OK); 3657963Seric else if (r == 552 || r == 554) 3667963Seric return (EX_UNAVAILABLE); 36758008Seric #ifdef LOG 36858020Seric if (LogLevel > 1) 36958008Seric { 37058008Seric syslog(LOG_CRIT, "%s: SMTP DATA-2 protocol error: %s", 37158008Seric e->e_id, SmtpReplyBuffer); 37258008Seric } 37358008Seric #endif 3747964Seric return (EX_PROTOCOL); 3754684Seric } 3764684Seric /* 3774865Seric ** SMTPQUIT -- close the SMTP connection. 3784865Seric ** 3794865Seric ** Parameters: 38015535Seric ** m -- a pointer to the mailer. 3814865Seric ** 3824865Seric ** Returns: 3834865Seric ** none. 3844865Seric ** 3854865Seric ** Side Effects: 3864865Seric ** sends the final protocol and closes the connection. 3874865Seric */ 3884865Seric 38953751Seric smtpquit(m, mci, e) 39053751Seric register MAILER *m; 39154967Seric register MCI *mci; 39253751Seric ENVELOPE *e; 3934865Seric { 3949391Seric int i; 3954865Seric 39654967Seric /* send the quit message if we haven't gotten I/O error */ 39753751Seric if (mci->mci_state != MCIS_ERROR) 3989391Seric { 39953751Seric smtpmessage("QUIT", m, mci); 40058112Seric (void) reply(m, mci, e, TimeOuts.to_quit); 40153740Seric if (mci->mci_state == MCIS_CLOSED) 40210159Seric return; 4039391Seric } 4049391Seric 40552676Seric /* now actually close the connection and pick up the zombie */ 40652676Seric i = endmailer(mci, m->m_argv[0]); 4079391Seric if (i != EX_OK) 40858151Seric syserr("451 smtpquit %s: stat %d", m->m_argv[0], i); 4094865Seric } 4104865Seric /* 41154967Seric ** SMTPRSET -- send a RSET (reset) command 41254967Seric */ 41354967Seric 41454967Seric smtprset(m, mci, e) 41554967Seric register MAILER *m; 41654967Seric register MCI *mci; 41754967Seric ENVELOPE *e; 41854967Seric { 41954967Seric int r; 42054967Seric 42154967Seric smtpmessage("RSET", m, mci); 42258112Seric r = reply(m, mci, e, TimeOuts.to_rset); 42357734Seric if (r < 0) 42457734Seric mci->mci_state = MCIS_ERROR; 42554967Seric else if (REPLYTYPE(r) == 2) 42657734Seric { 42757734Seric mci->mci_state = MCIS_OPEN; 42857734Seric return; 42957734Seric } 43057734Seric smtpquit(m, mci, e); 43154967Seric } 43254967Seric /* 43354967Seric ** SMTPNOOP -- send a NOOP (no operation) command to check the connection state 43454967Seric */ 43554967Seric 43654967Seric smtpnoop(mci) 43754967Seric register MCI *mci; 43854967Seric { 43954967Seric int r; 44054967Seric MAILER *m = mci->mci_mailer; 44154967Seric extern ENVELOPE BlankEnvelope; 44254967Seric ENVELOPE *e = &BlankEnvelope; 44354967Seric 44454967Seric smtpmessage("NOOP", m, mci); 44558112Seric r = reply(m, mci, e, TimeOuts.to_miscshort); 44658061Seric if (r < 0 || REPLYTYPE(r) != 2) 44754967Seric smtpquit(m, mci, e); 44854967Seric return r; 44954967Seric } 45054967Seric /* 4514684Seric ** REPLY -- read arpanet reply 4524684Seric ** 4534684Seric ** Parameters: 45410175Seric ** m -- the mailer we are reading the reply from. 45557379Seric ** mci -- the mailer connection info structure. 45657379Seric ** e -- the current envelope. 45757379Seric ** timeout -- the timeout for reads. 4584684Seric ** 4594684Seric ** Returns: 4604684Seric ** reply code it reads. 4614684Seric ** 4624684Seric ** Side Effects: 4634684Seric ** flushes the mail file. 4644684Seric */ 4654684Seric 46657379Seric reply(m, mci, e, timeout) 46753751Seric MAILER *m; 46854967Seric MCI *mci; 46953751Seric ENVELOPE *e; 4704684Seric { 47157379Seric if (mci->mci_out != NULL) 47257379Seric (void) fflush(mci->mci_out); 4734684Seric 4747677Seric if (tTd(18, 1)) 4754796Seric printf("reply\n"); 4764796Seric 4777356Seric /* 4787356Seric ** Read the input line, being careful not to hang. 4797356Seric */ 4807356Seric 4814684Seric for (;;) 4824684Seric { 4834684Seric register int r; 4847356Seric register char *p; 48553751Seric extern time_t curtime(); 4864684Seric 4877685Seric /* actually do the read */ 48853751Seric if (e->e_xfp != NULL) 48953751Seric (void) fflush(e->e_xfp); /* for debugging */ 4907356Seric 49110054Seric /* if we are in the process of closing just give the code */ 49253740Seric if (mci->mci_state == MCIS_CLOSED) 49310054Seric return (SMTPCLOSING); 49410054Seric 49558680Seric if (mci->mci_out != NULL) 49658680Seric fflush(mci->mci_out); 49758680Seric 49810054Seric /* get the line from the other side */ 49957379Seric p = sfgets(SmtpReplyBuffer, sizeof SmtpReplyBuffer, mci->mci_in, 50057379Seric timeout); 50153751Seric mci->mci_lastuse = curtime(); 50253751Seric 50310054Seric if (p == NULL) 50410131Seric { 50510148Seric extern char MsgBuf[]; /* err.c */ 50610148Seric 50721065Seric /* if the remote end closed early, fake an error */ 50821065Seric if (errno == 0) 50921065Seric # ifdef ECONNRESET 51021065Seric errno = ECONNRESET; 51156795Seric # else /* ECONNRESET */ 51221065Seric errno = EPIPE; 51356795Seric # endif /* ECONNRESET */ 51421065Seric 51557379Seric mci->mci_errno = errno; 51657642Seric mci->mci_exitstat = EX_TEMPFAIL; 51758151Seric message("451 %s: reply: read error from %s", 51857642Seric e->e_id == NULL ? "NOQUEUE" : e->e_id, 51957203Seric mci->mci_host); 52010420Seric /* if debugging, pause so we can see state */ 52110420Seric if (tTd(18, 100)) 52210420Seric pause(); 52310148Seric # ifdef LOG 52458020Seric if (LogLevel > 1) 52557203Seric syslog(LOG_INFO, "%s", &MsgBuf[4]); 52656795Seric # endif /* LOG */ 52754967Seric mci->mci_state = MCIS_ERROR; 52853751Seric smtpquit(m, mci, e); 52910054Seric return (-1); 53010131Seric } 53110054Seric fixcrlf(SmtpReplyBuffer, TRUE); 53210054Seric 53356795Seric if (e->e_xfp != NULL && strchr("45", SmtpReplyBuffer[0]) != NULL) 53414900Seric { 53514900Seric /* serious error -- log the previous command */ 53614900Seric if (SmtpMsgBuffer[0] != '\0') 53753751Seric fprintf(e->e_xfp, ">>> %s\n", SmtpMsgBuffer); 53814900Seric SmtpMsgBuffer[0] = '\0'; 53914900Seric 54014900Seric /* now log the message as from the other side */ 54153751Seric fprintf(e->e_xfp, "<<< %s\n", SmtpReplyBuffer); 54214900Seric } 54314900Seric 54414900Seric /* display the input for verbose mode */ 54558120Seric if (Verbose) 54658151Seric nmessage("%s", SmtpReplyBuffer); 5477356Seric 5487356Seric /* if continuation is required, we can go on */ 54958050Seric if (SmtpReplyBuffer[3] == '-' || 55058050Seric !(isascii(SmtpReplyBuffer[0]) && isdigit(SmtpReplyBuffer[0]))) 5514684Seric continue; 5527356Seric 5537356Seric /* decode the reply code */ 5549391Seric r = atoi(SmtpReplyBuffer); 5557356Seric 5567356Seric /* extra semantics: 0xx codes are "informational" */ 5574684Seric if (r < 100) 5584684Seric continue; 5597356Seric 56058061Seric /* save temporary failure messages for posterity */ 56158061Seric if (SmtpReplyBuffer[0] == '4' && SmtpError[0] == '\0') 56258061Seric (void) strcpy(SmtpError, SmtpReplyBuffer); 56358061Seric 5649391Seric /* reply code 421 is "Service Shutting Down" */ 56553740Seric if (r == SMTPCLOSING && mci->mci_state != MCIS_SSD) 5669391Seric { 56710054Seric /* send the quit protocol */ 56853740Seric mci->mci_state = MCIS_SSD; 56953751Seric smtpquit(m, mci, e); 5709391Seric } 5719391Seric 5724684Seric return (r); 5734684Seric } 5744684Seric } 5754796Seric /* 5764865Seric ** SMTPMESSAGE -- send message to server 5774796Seric ** 5784796Seric ** Parameters: 5794796Seric ** f -- format 58010175Seric ** m -- the mailer to control formatting. 5814796Seric ** a, b, c -- parameters 5824796Seric ** 5834796Seric ** Returns: 5844796Seric ** none. 5854796Seric ** 5864796Seric ** Side Effects: 58753740Seric ** writes message to mci->mci_out. 5884796Seric */ 5894796Seric 5904865Seric /*VARARGS1*/ 59157642Seric #ifdef __STDC__ 59257642Seric smtpmessage(char *f, MAILER *m, MCI *mci, ...) 59357642Seric #else 59457642Seric smtpmessage(f, m, mci, va_alist) 5954796Seric char *f; 59610175Seric MAILER *m; 59754967Seric MCI *mci; 59857642Seric va_dcl 59957642Seric #endif 6004796Seric { 60156852Seric VA_LOCAL_DECL 60256852Seric 60357135Seric VA_START(mci); 60456852Seric (void) vsprintf(SmtpMsgBuffer, f, ap); 60556852Seric VA_END; 60658680Seric 60758120Seric if (tTd(18, 1) || Verbose) 60858151Seric nmessage(">>> %s", SmtpMsgBuffer); 60953740Seric if (mci->mci_out != NULL) 61058680Seric { 61153740Seric fprintf(mci->mci_out, "%s%s", SmtpMsgBuffer, 61254967Seric m == NULL ? "\r\n" : m->m_eol); 61358680Seric } 61458680Seric else 615*58725Seric { 61658680Seric syserr("smtpmessage: NULL mci_out"); 617*58725Seric } 6184796Seric } 6195182Seric 62056795Seric # endif /* SMTP */ 621