*** ./collect.c.orig	Tue Feb  1 02:01:34 1994
--- ./collect.c	Fri Apr  8 13:10:07 1994
***************
*** 244,257 ****
  	}
  	else if (workbuf == buf2)	/* guarantee `buf' contains data */
  		(void) strcpy(buf, buf2);
  
  	/*
  	**  Collect the body of the message.
  	*/
  
  	for (;;)
! 	{
  		register char *bp = buf;
  
  		fixcrlf(buf, TRUE);
  
--- 244,279 ----
  	}
  	else if (workbuf == buf2)	/* guarantee `buf' contains data */
  		(void) strcpy(buf, buf2);
  
+ #ifdef EMIL
+ 
+ 	/* Connect collected header with MkMess_Root structure
+ 	 * and run the TCL scripts.
+ 	 */
+ 	if (CurEnv->e_from.q_mailer->m_charset) {
+ 	  Mk_Log(LOG_DEBUG, "Setting fromcharset %s from mailer %s",
+ 		 CurEnv->e_from.q_mailer->m_charset,
+ 		 CurEnv->e_from.q_mailer->m_name);
+ 	  MkMess_Root->fcharset = (char *)
+ 	    newstr(CurEnv->e_from.q_mailer->m_charset);
+ 	  MkMess_Root->esc = (short)CurEnv->e_from.q_mailer->m_esc;
+ 	}
+ 
+ 	MkMess_Root->header = (HDR *)CurEnv->e_header;
+ 	MkMess_Root->washeaders = TRUE;
+ 	MkMess_Root->investigate = TRUE;
+ 	Mk_Eval_Header();
+ 	linecount = 0;
+ 	MkMess_Buf->in = (char *)buf;
+ #endif /* EMIL */
+ 
  	/*
  	**  Collect the body of the message.
  	*/
  
  	for (;;)
! 	  {
  		register char *bp = buf;
  
  		fixcrlf(buf, TRUE);
  
***************
*** 273,280 ****
--- 295,305 ----
  		fputs(bp, tf);
  		fputs("\n", tf);
  		if (ferror(tf))
  			tferror(tf, e);
+ #ifdef EMIL
+ 		mkcollect(buf, sizeof(buf), InChannel);
+ #endif /* EMIL */
  		if (sfgets(buf, MAXLINE, InChannel, TimeOuts.to_datablock,
  				"message body read") == NULL)
  			goto readerr;
  	}
***************
*** 285,293 ****
  		if (tTd(30, 1))
  			printf("collect: read error\n");
  		inputerr = TRUE;
  	}
! 
  	if (fflush(tf) != 0)
  		tferror(tf, e);
  	if (fsync(fileno(tf)) < 0 || fclose(tf) < 0)
  	{
--- 310,324 ----
  		if (tTd(30, 1))
  			printf("collect: read error\n");
  		inputerr = TRUE;
  	}
! #ifdef EMIL
! 	if (MkMess_Curr->wait)
! 	  {
! 	    MkMess_Curr->enc = ENC7BIT;
! 	    MkMess_Curr->type = TYPETEXT;
! 	  }
! #endif /* EMIL */
  	if (fflush(tf) != 0)
  		tferror(tf, e);
  	if (fsync(fileno(tf)) < 0 || fclose(tf) < 0)
  	{
***************
*** 379,386 ****
--- 410,422 ----
  		/* we haven't acked receipt yet, so just chuck this */
  		syserr("Cannot reopen %s", e->e_df);
  		finis();
  	}
+ #ifdef EMIL
+ 	if (!MkMess_Curr->end_line)
+ 	  MkMess_Curr->end_line = linecount;
+ 	mkcollqueueup();
+ #endif /* EMIL */
  }
  /*
  **  FLUSHEOL -- if not at EOL, throw away rest of input line.
  **
*** ./conf.h.orig	Fri Mar 11 23:42:41 1994
--- ./conf.h	Fri Apr  8 13:10:07 1994
***************
*** 904,911 ****
--- 904,915 ----
  #endif
  
  
  /*
+ ** Define EMIL if you want to use the Emil message conversion system.
+ */
+ # define EMIL
+ /*
  **  Due to a "feature" in some operating systems such as Ultrix 4.3 and
  **  HPUX 8.0, if you receive a "No route to host" message (ICMP message
  **  ICMP_UNREACH_HOST) on _any_ connection, all connections to that host
  **  are closed.  Some firewalls return this error if you try to connect
*** ./deliver.c.orig	Fri Apr  8 13:58:40 1994
--- ./deliver.c	Fri Apr  8 13:11:44 1994
***************
*** 333,341 ****
  	int pid;
  	register ADDRESS *q;
  	char *qf;
  	char *id;
! 
  	/*
  	**  If we have had global, fatal errors, don't bother sending
  	**  the message at all if we are in SMTP mode.  Local errors
  	**  (e.g., a single address failing) will still cause the other
--- 333,343 ----
  	int pid;
  	register ADDRESS *q;
  	char *qf;
  	char *id;
! #ifdef EMIL
! 	HDR *mkroothdr;
! #endif
  	/*
  	**  If we have had global, fatal errors, don't bother sending
  	**  the message at all if we are in SMTP mode.  Local errors
  	**  (e.g., a single address failing) will still cause the other
***************
*** 452,460 ****
  	*/
  
  	e->e_nsent = 0;
  	e->e_flags |= EF_GLOBALERRS;
! 
  	/* now run through the queue */
  	for (q = e->e_sendqueue; q != NULL; q = q->q_next)
  	{
  #ifdef XDEBUG
--- 454,472 ----
  	*/
  
  	e->e_nsent = 0;
  	e->e_flags |= EF_GLOBALERRS;
! #ifdef EMIL
! 	/*
! 	 * Because Emil changes the headerstructure it is
! 	 * essential to refresh it for every copy to send
! 	 * if more than one.
! 	 */
! 	if (e->e_sendqueue->q_next != NULL)
! 	  mkroothdr = e->e_header;
! 	else
! 	  mkroothdr = NULL;
! #endif /* EMIL */
  	/* now run through the queue */
  	for (q = e->e_sendqueue; q != NULL; q = q->q_next)
  	{
  #ifdef XDEBUG
***************
*** 480,488 ****
--- 492,511 ----
  			}
  		}
  		else if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
  		{
+ #ifdef EMIL
+ 		  if (mkroothdr != NULL)
+ 		    {
+ 		      Mk_Log(LOG_DEBUG, "Copying header");
+ 		      e->e_header =
+ 			(HDR *)Mk_CopyHdr(mkroothdr);
+ 		      Mk_Tcl();
+ 		      Mk_Log(LOG_DEBUG, "Done");
+ 		    }
+ #endif /* EMIL */		  
  # ifdef QUEUE
+ 		  
  			/*
  			**  Checkpoint the send list every few addresses
  			*/
  
***************
*** 1299,1307 ****
  			/* try to execute the mailer */
  			execve(m->m_mailer, pv, env);
  			saveerrno = errno;
  			syserr("Cannot exec %s", m->m_mailer);
! 			if (m == LocalMailer || transienterror(saveerrno))
  				_exit(EX_OSERR);
  			_exit(EX_UNAVAILABLE);
  		}
  
--- 1322,1330 ----
  			/* try to execute the mailer */
  			execve(m->m_mailer, pv, env);
  			saveerrno = errno;
  			syserr("Cannot exec %s", m->m_mailer);
! 			if (!strncasecmp(m->m_name, "local", 5) || transienterror(saveerrno))
  				_exit(EX_OSERR);
  			_exit(EX_UNAVAILABLE);
  		}
  
***************
*** 1387,1403 ****
--- 1410,1477 ----
  		}
  	}
  	else if (!clever)
  	{
+ #ifdef EMIL
+ 	  /* Evaluate the message and decide what conversions should
+ 	   * be done
+ 	   */
+ 	  mkdeleval(m->m_mtype);
+ #endif /* EMIL */
+ 	  
  		/*
  		**  Format and send message.
  		*/
  
  		putfromline(mci, e);
  		(*e->e_puthdr)(mci, e);
  		putline("\n", mci);
+ #ifdef EMIL
+ 	  /*
+ 	   * If MkMess_Root->dotunnel send message without conversions.
+ 	   */
+ 	  if (MkMess_Root->dotunnel)
+ #endif /* EMIL */
  		(*e->e_putbody)(mci, e, NULL);
+ #ifdef EMIL
+ 	  else
+ 	    {
+ 	      /*
+ 	       * Send off each bodypart
+ 	       */
+ 	      linecount = 0;
+ 	      MkMess_Curr = MkMess_Root;
+ 	      do
+ 		{
+ 		  MkMess_Buf = MkMess_Curr->buf;
+ 		  if (MkMess_Curr != MkMess_Root)
+ 		    Mk_Put_Headers(mci, FALSE);
+ 		  MkMess_Curr->investigate = FALSE;
+ 		  (*e->e_putbody)(mci,  e, NULL);
+ 		  MkMess_Curr = MkMess_Curr->next;
+ 		} while (MkMess_Curr);
+ 	      
+ 	      Mk_Log(LOG_DEBUG, "Munging boundaries");
+ 	      if (MkMess_Curr != MkMess_Root && MkMess_Root->dosubheaders)
+ 		while (MkMess_Root->bound != NULL) 
+ 		  {
+ 		    char buf[BUFSIZE];
+ 		    char *boundbuf;
+ 		    boundbuf = (char *)getendbound();
+ 		    if (boundbuf) 
+ 		      {
+ 			strcpy(buf, boundbuf);
+ 			boundbuf = buf;
+ 			putline(boundbuf, mci->mci_out, m);
+ 		      }
+ 		    rmlastbound();
+ 		  }
+ 	    }
+ 	  Mk_Log(LOG_DEBUG, "Processing done");
+ #endif /* EMIL */
  
+ 	  
+ 
  		/* get the exit status */
  		rcode = endmailer(mci, e, pv);
  	}
  	else
***************
*** 2070,2078 ****
  			putline("<<< No Message Collected >>>", mci);
  	}
  	if (e->e_dfp != NULL)
  	{
! 		rewind(e->e_dfp);
  		while (!ferror(mci->mci_out) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
  		{
  			if (buf[0] == 'F' &&
  			    bitnset(M_ESCFROM, mci->mci_mailer->m_flags) &&
--- 2144,2166 ----
  			putline("<<< No Message Collected >>>", mci);
  	}
  	if (e->e_dfp != NULL)
  	{
! #ifdef EMIL
!         /* Just in case it screwed up
!          */
!         if (MkMess_Curr == NULL) {
!           MkMess_Curr = MkMess_Root;
!           MkMess_Root->dotunnel = TRUE;
!         }
!         else
!           if (MkMess_Curr == MkMess_Root || MkMess_Root->dotunnel)
! #endif /* EMIL */
!                 rewind(e->e_dfp);
! #ifdef EMIL
!         if (MkMess_Root->dotunnel)
! #endif /* EMIL */
! 
  		while (!ferror(mci->mci_out) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
  		{
  			if (buf[0] == 'F' &&
  			    bitnset(M_ESCFROM, mci->mci_mailer->m_flags) &&
***************
*** 2087,2094 ****
--- 2175,2186 ----
  					(void) putc(' ', mci->mci_out);
  			}
  			putline(buf, mci);
  		}
+ #ifdef EMIL
+         else
+           mkputbodypart(e->e_dfp, mci);
+ #endif /* EMIL */
  
  		if (ferror(e->e_dfp))
  		{
  			syserr("putbody: %s: read error", e->e_df);
*** ./envelope.c.orig	Sat Feb 26 05:33:27 1994
--- ./envelope.c	Fri Apr  8 13:10:08 1994
***************
*** 249,256 ****
--- 249,260 ----
  		if (tTd(50, 1))
  			printf("\n===== Dropping [dq]f%s =====\n\n", e->e_id);
  		if (e->e_df != NULL)
  			xunlink(e->e_df);
+ #ifdef EMIL
+ 		if (e->e_mf != NULL)
+ 		  xunlink(e->e_mf);
+ #endif /* EMIL */
  		xunlink(queuename(e, 'q'));
  
  #ifdef LOG
  		if (LogLevel > 10)
***************
*** 392,400 ****
  	define('c', newstr(cbuf), e);
  
  	/* time as integer, unix time, arpa time */
  	settime(e);
! 
  #ifdef TTYNAME
  	/* tty name */
  	if (macvalue('y', e) == NULL)
  	{
--- 396,406 ----
  	define('c', newstr(cbuf), e);
  
  	/* time as integer, unix time, arpa time */
  	settime(e);
! #ifdef EMIL
! 	Mk_Tcl();
! #endif /* EMIL */
  #ifdef TTYNAME
  	/* tty name */
  	if (macvalue('y', e) == NULL)
  	{
***************
*** 657,665 ****
  	}
  	SuprErrs = FALSE;
  
  	pvp = NULL;
! 	if (e->e_from.q_mailer == LocalMailer)
  	{
  # ifdef USERDB
  		register char *p;
  		extern char *udbsender();
--- 663,671 ----
  	}
  	SuprErrs = FALSE;
  
  	pvp = NULL;
! 	if (!strncasecmp(e->e_from.q_mailer->m_name, "local", 5))
  	{
  # ifdef USERDB
  		register char *p;
  		extern char *udbsender();
*** ./queue.c.orig	Sun Mar  6 18:00:57 1994
--- ./queue.c	Fri Apr  8 13:10:09 1994
***************
*** 166,175 ****
  			printf("NULL\n");
  		else
  			dumpfd(fileno(e->e_lockfp), TRUE, FALSE);
  	}
! 
  	/*
  	**  If there is no data file yet, create one.
  	*/
  
  	if (e->e_df == NULL)
--- 166,185 ----
  			printf("NULL\n");
  		else
  			dumpfd(fileno(e->e_lockfp), TRUE, FALSE);
  	}
! #ifdef EMIL
  	/*
+ 	 * If there is no message control file yet, create one.
+ 	 */
+ 	if (e->e_mf == NULL)
+ 	  {
+ 	    char *qp;
+ 	    qp = queuename(e, 'm');
+ 	    e->e_mf = newstr(qp);
+ 	  }
+ #endif /* EMIL */
+ 	/*
  	**  If there is no data file yet, create one.
  	*/
  
  	if (e->e_df == NULL)
***************
*** 543,551 ****
  	**	First, read and sort the entire queue.
  	**	Then, process the work in that order.
  	**		But if you take too long, start over.
  	*/
! 
  	/* order the existing work requests */
  	(void) orderq(FALSE);
  
  	/* process them once at a time */
--- 553,563 ----
  	**	First, read and sort the entire queue.
  	**	Then, process the work in that order.
  	**		But if you take too long, start over.
  	*/
! #ifdef EMIL
! 	Mk_Tcl();
! #endif /* EMIL */
  	/* order the existing work requests */
  	(void) orderq(FALSE);
  
  	/* process them once at a time */
***************
*** 925,933 ****
  		}
  
  		e->e_flags |= EF_INQUEUE;
  		eatheader(e, requeueflag);
! 
  		if (requeueflag)
  			queueup(e, TRUE, FALSE);
  
  		/* do the delivery */
--- 937,963 ----
  		}
  
  		e->e_flags |= EF_INQUEUE;
  		eatheader(e, requeueflag);
! #ifdef EMIL
! 		e->e_mf = newstr(queuename(e, 'm'));
! 		if (TRUE)
! 		  {
! 		    FILE *mfp;
! 		    if ((mfp = fopen(e->e_mf, "r")) == NULL)
! 		      {
! 			syslog(LOG_NOTICE, "Emil: Cannot open %s ...using transparent mode",
! 			       e->e_mf);
! 			MkMess_Root->dotunnel = TRUE;
! 		      }
! 		    else
! 		      {
! 			mkreadqf(mfp, MkMess_Root);
! 			fclose(mfp);
! 		      }
! 		  }
! #endif /* EMIL */
! 				 
  		if (requeueflag)
  			queueup(e, TRUE, FALSE);
  
  		/* do the delivery */
*** ./readcf.c.orig	Mon Mar 21 22:05:34 1994
--- ./readcf.c	Fri Apr  8 13:10:09 1994
***************
*** 687,694 ****
--- 687,697 ----
  **			   A -- the argv for this mailer
  **			   S -- the sender rewriting set
  **			   R -- the recipient rewriting set
  **			   E -- the eol string
+ **                         T -- the message type
+ **                         C -- the default charset
+ **                         X -- the default escape
  **			The first word is the canonical name of the mailer.
  **
  **	Returns:
  **		none.
***************
*** 807,814 ****
--- 810,828 ----
  
  		  case 'D':		/* working directory */
  			m->m_execdir = newstr(p);
  			break;
+ #ifdef EMIL
+ 		      case 'T':
+ 			m->m_mtype = newstr(p);
+ 			break;
+ 		      case 'C':
+ 			m->m_charset = newstr(p);
+ 			break;
+ 		      case 'X':
+ 			m->m_esc = atol(p);
+ 			break;
+ #endif /* EMIL */
  		}
  
  		p = delimptr;
  	}
*** ./sendmail.h.orig	Sun Feb  6 23:07:39 1994
--- ./sendmail.h	Fri Apr  8 13:10:09 1994
***************
*** 178,185 ****
--- 178,190 ----
  	short	m_rh_rwset;	/* rewrite set: recipient header addresses */
  	short	m_re_rwset;	/* rewrite set: recipient envelope addresses */
  	char	*m_eol;		/* end of line string */
  	long	m_maxsize;	/* size limit on message to this mailer */
+ #ifdef EMIL
+ 	char    *m_mtype;       /* Emil script name */
+         char    *m_charset;
+ 	short   m_esc;
+ #endif /* EMIL */
  	int	m_linelimit;	/* max # characters per line */
  	char	*m_execdir;	/* directory to chdir to before execv */
  };
  
***************
*** 353,360 ****
--- 358,369 ----
  	FILE		*e_dfp;		/* temporary file */
  	char		*e_id;		/* code for this entry in queue */
  	FILE		*e_xfp;		/* transcript file */
  	FILE		*e_lockfp;	/* the lock file for this message */
+ #ifdef EMIL
+ 	char            *e_mf;          /* location of message file */
+ 	FILE            *e_mfp;         /* message file */
+ #endif /* EMIL */
  	char		*e_message;	/* error message */
  	char		*e_statmsg;	/* stat msg (changes per delivery) */
  	char		*e_msgboundary;	/* MIME-style message part boundary */
  	char		*e_origrcpt;	/* original recipient (one only) */
***************
*** 968,971 ****
--- 977,985 ----
  extern void		usrerr();
  extern void		message();
  extern void		nmessage();
  #endif
+ # ifdef EMIL
+ #   include "../emil/charset/iso646.h"
+ #   include "../emil/charset/charset.h"
+ #   include "../emil/mkspec.h"
+ # endif /* EMIL */
*** ./srvrsmtp.c.orig	Tue Mar  8 19:32:38 1994
--- ./srvrsmtp.c	Fri Apr  8 13:10:10 1994
***************
*** 291,298 ****
--- 291,301 ----
  			if (MaxMessageSize > 0)
  				message("250-SIZE %ld", MaxMessageSize);
  			else
  				message("250-SIZE");
+ #ifdef EMIL
+ 			message("250-8BITMIME");
+ #endif
  			message("250 HELP");
  			break;
  
  		  case CMDMAIL:		/* mail -- designate sender */
***************
*** 379,387 ****
  				*p++ = '\0';
  
  			/* check for possible spoofing */
  			if (RealUid != 0 && OpMode == MD_SMTP &&
! 			    (e->e_from.q_mailer != LocalMailer &&
  			     strcmp(e->e_from.q_user, RealUserName) != 0))
  			{
  				auth_warning(e, "%s owned process doing -bs",
  					RealUserName);
--- 382,390 ----
  				*p++ = '\0';
  
  			/* check for possible spoofing */
  			if (RealUid != 0 && OpMode == MD_SMTP &&
! 			    (strncasecmp(e->e_from.q_mailer->m_name, "local", 5) &&
  			     strcmp(e->e_from.q_user, RealUserName) != 0))
  			{
  				auth_warning(e, "%s owned process doing -bs",
  					RealUserName);
*** ./usersmtp.c.orig	Fri Apr  8 13:58:52 1994
--- ./usersmtp.c	Fri Apr  8 13:11:44 1994
***************
*** 359,367 ****
  		bufp = &buf[1];
  	}
  	else
  		bufp = buf;
! 	if (e->e_from.q_mailer == LocalMailer ||
  	    !bitnset(M_FROMPATH, m->m_flags))
  	{
  		smtpmessage("MAIL From:<%s>%s", m, mci, bufp, optbuf);
  	}
--- 359,367 ----
  		bufp = &buf[1];
  	}
  	else
  		bufp = buf;
! 	if (!strncasecmp(e->e_from.q_mailer->m_name, "local", 5) ||
  	    !bitnset(M_FROMPATH, m->m_flags))
  	{
  		smtpmessage("MAIL From:<%s>%s", m, mci, bufp, optbuf);
  	}
***************
*** 536,548 ****
--- 536,587 ----
  	if (timeout < (time_t) 60)
  		timeout = (time_t) 60;
  	timeout += e->e_nrcpts * 90;
  	ev = setevent(timeout, datatimeout, 0);
+ #ifdef EMIL
+ 	if (mci->mci_flags & MCIF_8BITMIME)
+ 	  mkdeleval("8bitmime");
+ 	else
+ 	  mkdeleval(m->m_mtype);
+ #endif /* EMIL */
  
  	/* now output the actual message */
  	(*e->e_puthdr)(mci, e);
  	putline("\n", mci);
+ 
+ #ifdef EMIL
+ 	if (MkMess_Root->dotunnel)
+ #endif /* EMIL */
+ 
  	(*e->e_putbody)(mci, e, NULL);
+ #ifdef EMIL
+ 	else
+ 	  {
+ 	    linecount = 0;
+ 	    MkMess_Curr = MkMess_Root;
+ 	    do
+ 	      {
+ 		MkMess_Buf = MkMess_Curr->buf;
+ 		if (MkMess_Curr != MkMess_Root)
+ 		  Mk_Put_Headers(mci,  FALSE);
+ 		MkMess_Curr->investigate = FALSE;
+ 		(*e->e_putbody)(mci, e, NULL);
+ 		MkMess_Curr = MkMess_Curr->next;
+ 	      } while (MkMess_Curr);
+ 	    while (MkMess_Root->bound != NULL) {
+ 	      char buf[BUFSIZE];
+ 	      char *boundbuf;
+ 	      boundbuf = (char *)getendbound();
+ 	      if (boundbuf) {
+ 		strcpy(buf, boundbuf);
+ 		boundbuf = buf;
+ 		putline(boundbuf, mci);
+ 	      }
+ 	      rmlastbound();
+ 	    }
+ 	  }
+ 	Mk_Log(LOG_DEBUG, "Processing done");
+ #endif /* EMIL */
  
  	clrevent(ev);
  
  	if (ferror(mci->mci_out))
*** ./util.c.orig	Fri Mar 11 20:09:34 1994
--- ./util.c	Fri Apr  8 13:10:10 1994
***************
*** 106,113 ****
--- 106,117 ----
  		syserr("Out of memory!!");
  		abort();
  		/* exit(EX_UNAVAILABLE); */
  	}
+ #ifdef EMIL
+ 	/* Emil depends on xalloc bzeroing the areas */
+ 	bzero(p, (unsigned)sz);
+ #endif /* EMIL */
  	return (p);
  }
  /*
  **  COPYPLIST -- copy list of pointers.
***************
*** 695,711 ****
  {
  	register char *p;
  	register char svchar;
  	int slop = 0;
! 
  	/* strip out 0200 bits -- these can look like TELNET protocol */
  	if (bitset(MCIF_7BIT, mci->mci_flags))
  	{
  		for (p = l; (svchar = *p) != '\0'; ++p)
  			if (bitset(0200, svchar))
  				*p = svchar &~ 0200;
  	}
! 
  	do
  	{
  		/* find the end of the line */
  		p = strchr(l, '\n');
--- 699,715 ----
  {
  	register char *p;
  	register char svchar;
  	int slop = 0;
! #ifndef EMIL
  	/* strip out 0200 bits -- these can look like TELNET protocol */
  	if (bitset(MCIF_7BIT, mci->mci_flags))
  	{
  		for (p = l; (svchar = *p) != '\0'; ++p)
  			if (bitset(0200, svchar))
  				*p = svchar &~ 0200;
  	}
! #endif /* EMIL */
  	do
  	{
  		/* find the end of the line */
  		p = strchr(l, '\n');
***************
*** 900,910 ****
--- 904,916 ----
  		return (NULL);
  	}
  	if (TrafficLogFile != NULL)
  		fprintf(TrafficLogFile, "%05d <<< %s", getpid(), buf);
+ #ifndef EMIL
  	if (SevenBit)
  		for (p = buf; *p != '\0'; p++)
  			*p &= ~0200;
+ #endif
  	return (buf);
  }
  
  static
*** ./version.c.orig	Sat Mar 19 00:37:06 1994
--- ./version.c	Fri Apr  8 13:10:11 1994
***************
*** 35,39 ****
--- 35,43 ----
  #ifndef lint
  static char sccsid[] = "@(#)version.c	8.6.8.1 (Berkeley) 3/18/94";
  #endif /* not lint */
  
+ #ifdef EMIL
+ char    Version[] = "8.6.5+Emil1.1";
+ #else
  char	Version[] = "8.6.8.1";
+ #endif
*** ./alias.c.orig	Mon Feb 28 19:05:15 1994
--- ./alias.c	Fri Apr  8 13:10:11 1994
***************
*** 635,643 ****
  				usrerr("554 alias too long");
  				break;
  			}
  		}
! 		if (al.q_mailer != LocalMailer)
  		{
  			syserr("554 %s... cannot alias non-local names",
  				al.q_paddr);
  			continue;
--- 635,643 ----
  				usrerr("554 alias too long");
  				break;
  			}
  		}
! 		if (strncasecmp(al.q_mailer->m_name, "local", 5))
  		{
  			syserr("554 %s... cannot alias non-local names",
  				al.q_paddr);
  			continue;
***************
*** 709,717 ****
  
  	if (tTd(27, 1))
  		printf("forward(%s)\n", user->q_paddr);
  
! 	if (user->q_mailer != LocalMailer || bitset(QBADADDR, user->q_flags))
  		return;
  	if (user->q_home == NULL)
  	{
  		syserr("554 forward: no home");
--- 709,717 ----
  
  	if (tTd(27, 1))
  		printf("forward(%s)\n", user->q_paddr);
  
! 	if (strncasecmp(user->q_mailer->m_name, "local", 5) || bitset(QBADADDR, user->q_flags))
  		return;
  	if (user->q_home == NULL)
  	{
  		syserr("554 forward: no home");
*** ./conf.c.orig	Sun Mar  6 18:31:35 1994
--- ./conf.c	Fri Apr  8 13:10:11 1994
***************
*** 519,527 ****
  	/* this code is intended as an example only */
  	register STAB *s;
  
  	s = stab("arpa", ST_MAILER, ST_FIND);
! 	if (s != NULL && e->e_from.q_mailer != LocalMailer &&
  	    to->q_mailer == s->s_mailer)
  	{
  		usrerr("553 No ARPA mail through this machine: see your system administration");
  		/* NoReturn = TRUE; to supress return copy */
--- 519,527 ----
  	/* this code is intended as an example only */
  	register STAB *s;
  
  	s = stab("arpa", ST_MAILER, ST_FIND);
! 	if (s != NULL && strncasecmp(e->e_from.q_mailer->m_name, "local", 5) &&
  	    to->q_mailer == s->s_mailer)
  	{
  		usrerr("553 No ARPA mail through this machine: see your system administration");
  		/* NoReturn = TRUE; to supress return copy */
*** ./headers.c.orig	Thu Mar  3 00:36:11 1994
--- ./headers.c	Fri Apr  8 13:10:12 1994
***************
*** 182,190 ****
  			if (OpMode == MD_SMTP || OpMode == MD_ARPAFTP)
  				SuprErrs = TRUE;
  			fancy = crackaddr(fvalue);
  			if (parseaddr(fvalue, &a, RF_COPYNONE, '\0', NULL, e) != NULL &&
! 			    a.q_mailer == LocalMailer &&
  			    (p = udbsender(a.q_user)) != NULL)
  			{
  				char *oldg = macvalue('g', e);
  
--- 182,190 ----
  			if (OpMode == MD_SMTP || OpMode == MD_ARPAFTP)
  				SuprErrs = TRUE;
  			fancy = crackaddr(fvalue);
  			if (parseaddr(fvalue, &a, RF_COPYNONE, '\0', NULL, e) != NULL &&
! 			    !strncasecmp(a.q_mailer->m_name, "local", 5) &&
  			    (p = udbsender(a.q_user)) != NULL)
  			{
  				char *oldg = macvalue('g', e);
  
*** ./parseaddr.c.orig	Wed Feb  9 20:32:47 1994
--- ./parseaddr.c	Fri Apr  8 13:10:12 1994
***************
*** 1394,1402 ****
  	}
  	tv++;
  
  	/* do special mapping for local mailer */
! 	if (m == LocalMailer && *tv != NULL)
  	{
  		register char *p = *tv;
  
  		if (*p == '"')
--- 1394,1402 ----
  	}
  	tv++;
  
  	/* do special mapping for local mailer */
! 	if (!strncasecmp(m->m_name, "local", 5) && *tv != NULL)
  	{
  		register char *p = *tv;
  
  		if (*p == '"')
***************
*** 1419,1427 ****
  			}
  		}
  	}
  
! 	if (m == LocalMailer && *tv != NULL && strcmp(*tv, "@") == 0)
  	{
  		tv++;
  		a->q_flags |= QNOTREMOTE;
  	}
--- 1419,1427 ----
  			}
  		}
  	}
  
! 	if (!strncasecmp(m->m_name, "local", 5) && *tv != NULL && strcmp(*tv, "@") == 0)
  	{
  		tv++;
  		a->q_flags |= QNOTREMOTE;
  	}
*** ./recipient.c.orig	Mon Feb 28 19:05:14 1994
--- ./recipient.c	Fri Apr  8 13:10:12 1994
***************
*** 352,360 ****
  			giveresponse(EX_CANTCREAT, m, NULL, a->q_alias, e);
  		}
  	}
  
! 	if (m != LocalMailer)
  	{
  		if (!bitset(QDONTSEND, a->q_flags))
  			e->e_nrcpts++;
  		goto testselfdestruct;
--- 352,360 ----
  			giveresponse(EX_CANTCREAT, m, NULL, a->q_alias, e);
  		}
  	}
  
! 	if (strncasecmp(m->m_name, "local", 5))
  	{
  		if (!bitset(QDONTSEND, a->q_flags))
  			e->e_nrcpts++;
  		goto testselfdestruct;
*** ./savemail.c.orig	Fri Mar 11 23:42:35 1994
--- ./savemail.c	Fri Apr  8 13:10:13 1994
***************
*** 186,194 ****
  
  		switch (state)
  		{
  		  case ESM_QUIET:
! 			if (e->e_from.q_mailer == LocalMailer)
  				state = ESM_DEADLETTER;
  			else
  				state = ESM_MAIL;
  			break;
--- 186,194 ----
  
  		switch (state)
  		{
  		  case ESM_QUIET:
! 			if (!strncasecmp(e->e_from.q_mailer->m_name, "local", 5))
  				state = ESM_DEADLETTER;
  			else
  				state = ESM_MAIL;
  			break;
***************
*** 329,337 ****
  			**	what poor typists UNIX users are.
  			*/
  
  			p = NULL;
! 			if (e->e_from.q_mailer == LocalMailer)
  			{
  				if (e->e_from.q_home != NULL)
  					p = e->e_from.q_home;
  				else if ((pw = getpwnam(e->e_from.q_user)) != NULL)
--- 329,337 ----
  			**	what poor typists UNIX users are.
  			*/
  
  			p = NULL;
! 			if (!strncasecmp(e->e_from.q_mailer->m_name, "local", 5))
  			{
  				if (e->e_from.q_home != NULL)
  					p = e->e_from.q_home;
  				else if ((pw = getpwnam(e->e_from.q_user)) != NULL)
