[comp.unix.questions] how do i get mail

jon@jonlab.UUCP (Jon H. LaBadie) (09/07/88)

On a SVR2 system, I've installed smail 2.5, and netnews 2.11.
Using mail (aliased to mailx via ksh), and setting the mailx
options in ".mailrc", I am able to save copies of my outgoing
mail: a feature I greatly appreciate!

The problem comes when I try to reply to a netnews article
by mailing to the author directly rather than posting a new
article, i.e., using the "r" command in vnews.  Unfortunately,
these mailings are not saved.

Any suggestions on how to automatically save outgoing mail
sent from within vnews?

-- 
Jon LaBadie
{att, ulysses, princeton, bcr}!jonlab!jon

sullivan@vsi.UUCP (Michael T Sullivan) (09/08/88)

Note that this was originally posted to comp.unix.questions, but I thought
the followup should be cross-posted to news.admin.

In article <459@jonlab.UUCP>, jon@jonlab.UUCP (Jon H. LaBadie) writes:
> Any suggestions on how to automatically save outgoing mail
> sent from within vnews?

I modified our news to use mailx a few weeks ago.  I've been meaning to
post this, but I guess I'm just lazy.

A little background.  mailx(1) has the facility to save your outgoing
mail messages.  Problem is even if you have your news mailer be mailx,
your messages won't be saved in your obox because inews runs setuid and
setgid of the news administrator.  At first I just put a setuid(getuid())
after news forked off but before it exec'd the mailer.  This saved the
messages in the obox but it messed up the subject line (it didn't show
up).  Being lazy, I let this go on for a few months.  Then I got inspired
and did this.

Sorry this isn't in diff format, if that is what you expected.  I didn't
keep the original around since everything I added is #ifdef'd.  Below
I have the area of code you need to modify.  The idea is that if you
want to use mailx as your mailer just insert the "#ifdef MAILX" stuff,
put -DMAILX in CFLAGS in your Makefile, and recompile.  If you have any
problems (you shouldn't, this is pretty straightforward) just drop me a
line.  Since I made these changes here there have been no problems.

==================================================

readr.c about line #784:

		if ((tfp = fopen(tf, "w")) == NULL) {
			perror(tf);
			creatm = 0L;
		} else {
			fprintf(tfp, "To: %s\n", pathptr);
> #ifdef MAILX
> 			fprintf(tfp, "~s %s\n", subj);
> #else
> 			fprintf(tfp, "Subject: %s\n", subj);
> #endif
#ifdef INTERNET
			fprintf(tfp, "News-Path: %s\n", hptr->path);
#endif /* INTERNET */
			fprintf(tfp, "References: %s\n\n", folbuf);
			fstat(fileno(tfp), &statb);
			creatm = statb.st_mtime;
			(void) fclose(tfp);
		}
		(void) umask(oumask);

==================================================

recmail.c about line #61:

	while (fgets(linebuf, sizeof linebuf, stdin) != NULL) {
	   	 if ((strncmp(linebuf, "Bcc: ", 5) == 0 ||
		    strncmp(linebuf, "bcc: ", 5) == 0 ||
		    strncmp(linebuf, "BCC: ", 5) == 0)) {
		    if (linebuf[5] != '\n')
			addrecips(linebuf+5);
		    }
> #ifdef MAILX
> 		/*
> 		*	mailx will add the To: line for us.
> 		*/
> 		else if (strncmp(linebuf, "To: ", 4) == 0 ||
> 		    strncmp(linebuf, "to: ", 4) == 0 ||
> 		    strncmp(linebuf, "TO: ", 4) == 0)
> 			;
> #endif
		else if (fputs(linebuf, fd) == EOF)
			goto werror;
		if (linebuf[0] == '\n')
			break;
		if ((strncmp(linebuf, "To: ", 4) == 0 ||
		    strncmp(linebuf, "to: ", 4) == 0 ||
		    strncmp(linebuf, "TO: ", 4) == 0 ||
		    strncmp(linebuf, "Cc: ", 4) == 0 ||
		    strncmp(linebuf, "cc: ", 4) == 0 ||
		    strncmp(linebuf, "CC: ", 4) == 0) &&
		     linebuf[4] != '\n')
			addrecips(linebuf+4);
	}

==================================================

recmail.c about line 210:

	if (pid == 0) {
		(void) close(0);
		(void) open(tmpf, 0);
		if (errfd != NULL) {
			(void) close(1);
			(void) dup(fileno(errfd));
			(void) fclose(errfd);
			(void) close(2);
			(void) dup(1);
		}
> #ifdef MAILX
> 		/*
> 		*	This program is running suid usenet.  To read .mailrc
> 		*	we need to use the real id.
> 		*/
> 		setuid(getuid());
> #endif
		execlp(mailer, mailer, recip, (char *)0);
		perror(mailer);
		exit(1);
	}

==================================================

visual.c about line #1018:

	p = replyname(h);
	fprintf(rfp, "To: %s\n", p);
> #ifdef MAILX
> 	fprintf(rfp, "~s %s\n", subj);
> #else
>	fprintf(rfp, "Subject: %s\n", subj);
> #endif
	fprintf(rfp, "In-reply-to: your article %s\n", h->ident);
#ifdef INTERNET
	fprintf(rfp, "News-Path: %s\n", h->path);
#endif /* INTERNET */
	(void) sprintf(rcbuf, "%s -t < %s; rm -f %s", MAILPARSER, tf, tf);
	putc('\n', rfp);
-- 
Michael Sullivan				{uunet|attmail}!vsi!sullivan
V-Systems, Inc. Santa Ana, CA			sullivan@vsi.com
whump, whump, whump, whump, whump, whump, whump, whump, whump, whump, whump

domo@riddle.UUCP (Dominic Dunlop) (09/17/88)

In article <459@jonlab.UUCP> jon@jonlab.UUCP (Jon H. LaBadie) writes:
>On a SVR2 system, I've installed smail 2.5, and netnews 2.11.
>Using mail (aliased to mailx via ksh), and setting the mailx
>options in ".mailrc", I am able to save copies of my outgoing
>mail: a feature I greatly appreciate!

I'm lazy.  One of these days, I'll get around to editing the Rnmail script
so that it automatically puts the user's logname on the Bcc: header line
of outgoing mail.  Then all the user has to do is transfer it from the
mailbox to their outgoing mail copy file the next time they read their
mail.  Not a complete or elegant solution, but an easy hack.

(For a complete and elegant solution, I'm sure the long C language posting,
834@vsi.UUCP from Michael Sullivan, is much better.)
-- 
Dominic Dunlop
domo@sphinx.co.uk  domo@riddle.uucp