🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #10538

Re: tin and mailer aliases - please help!

#10538
From: Frederik Ramm
Date: Tue, 02 Aug 1994 08:46
140 lines
4887 bytes
Arnold Shore (ashore@access1.digex.net) wrote:
: Using tin 1.2 PL2, I'm trying to get at my elm aliases without success.  
: I'm using the info in FAQ para 3.3, and have edited the noted parameter 
: line into the tinrc file.

I use my elm aliases with tin the following way: I've set the environment
variable MAILER to a small program named 'elmcall' which someone in some
newsgroup once sent me :-)... this 'elmcall' calls elm which then sends the
mail.

You can also use 'elm' directly as a mailer but then it may happen that
your subject line is replaces with "no subject - file transmision", 
which is the reason for using 'elmcall' - it takes the subject and puts
it onto the elm command line (or was it vice versa?) to avoid this.

Here goes elmcall.c: (Sorry I've forgotten the author and can't credit
him but it was a great idea):

/* Fix to use elm as mailer for tin
 * -- Reads standard in, finds subject, and sends to elm
 * to mail.  If a subject line exists it is removed,as elm adds it back in.
 * Advantage over tin builtin mailer is that
 * messages get written to elm 'sent' folder, and elm aliases can be used.
 * This code written rather than hacking tin, so that I don't have to search
 * out every occurance of mailing .... wold not be so much of a problem if 
 * invoke-mailer() routine actually existed.
 * @(#) tin_mailer.c 1.3@(#) R.E.May. BBC Research Department. December 1993.
 * usage: tin_mailer to_addr [ to_addr ... ] < send_file 
 */
/* Compile using ansi c compiler (I've only tried it with gcc, although it
 * should be straightfoward to hack it to work with standard cc.)
 * i.e. gcc -O -o tin_mailer tin_mailer.c
 * Then set environmental variable MAILER to the path of this program.
 * e.g for c-shell users setenv MAILER ~/bin/tin_mailer
 * and for bourne-shell users MAILER=~/bin/tin_mailer;export MAILER
 * try it and see !!
 */
#include <stdio.h>
#include <string.h>
#define LEN 1024
#define FALSE 0
#define TRUE 1
/* set MAILER to the full path of your elm executable */
#define MAILER "/usr/bin/elm"

void my_strncpy (char *p, char *q, int n);

void main(int argc, char *argv[])
{
	char buf[LEN];
	char subj[LEN];
	char mailer[LEN];
	char mail_to[LEN];
	char cmd[LEN];
	char tmpfile[L_tmpnam];
	char *p;
	int found = FALSE;
	int i;
	FILE *fp;

	*subj = '\0';

	strcpy(mailer,MAILER);
	/* get mail_to address(es) */
	if(argc > 1)
	{
		strcpy(mail_to,argv[1]);
		if(argc > 2)
		{
			for(i=2;i<argc;i++)
			{
				strcat(mail_to," ");
				strcat(mail_to,argv[i]);
			}
		}
	}
	else
	{
		fprintf(stderr,"%s: No address to send mail to\n",argv[0]);
		exit(1);
	}

	/* get a tmp file name */
	(void)tmpnam(tmpfile);
	if((fp = fopen(tmpfile,"w")) ==NULL)
	{
		fprintf(stderr,"%s: could not open tmp file %s.\n",argv[0],tmpfile);
		exit(1);
	}

	/* find first Subject:  line, and keep its contents.
	 * write anything else to the tmp file.
	 * Don't write Subject:  line, as elm will add it
	 */
	while (fgets (buf, sizeof (buf), stdin) != NULL)
	{
		if (!found && strncmp (buf, "Subject: ", 9) == 0)
		{
			my_strncpy (subj, &buf[9], sizeof (subj));
			found = TRUE;
		}
		else
			fputs(buf,fp);
	}

	(void)fclose(fp);

	/* If we didn't find a Subject: line in the text to be posted
	 * make one up ...
	 */
	if(!found)
		sprintf(subj,"%s: No Subject",argv[0]);

	sprintf(cmd,"%s -s \"%s\" \"%s\" < %s",mailer,subj,mail_to,tmpfile);
	system(cmd);

	/* remove tmp file */
	if(unlink(tmpfile) == -1)
	{
		fprintf(stderr,"%s: could not remove tmp file %s\n",argv[0],tmpfile);
		exit(1);
	}

	exit(0);
}

/* copy up to n characters */
/* don't copy RETURN char, if there is one */
void my_strncpy (char *p, char *q, int n)
{
	while (n--) {
		if (! *q || *q == '\n')
			break;
		*p++ = *q++;
	}
	*p = '\0';
}

--
Frederik Ramm  ##  eMail ule3@rz.uni-karlsruhe.de  ## fax +49 721 379786
Technical Details
Message-ID: <31l14m$mvi@nz12.rz.uni-karlsruhe.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!bga.com!news.sprintlink.net!hookup!usc!howland.reston.ans.net!EU.net!Germany.EU.net!netmbx.de!zib-berlin.de!news.uni-ulm.de!rz.uni-karlsruhe.de!rzstud1.rz.uni-karlsruhe.de!ule3
References: <318dfu$27t@news1.digex.net>

Show Full Headers
Complete Article Headers
Message-ID: <31l14m$mvi@nz12.rz.uni-karlsruhe.de>
Subject: Re: tin and mailer aliases - please help!
Date: Tue, 02 Aug 1994 08:46:14 +0000
From: ule3@rzstud1.rz.uni-karlsruhe.de (Frederik Ramm)
References: <318dfu$27t@news1.digex.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!bga.com!news.sprintlink.net!hookup!usc!howland.reston.ans.net!EU.net!Germany.EU.net!netmbx.de!zib-berlin.de!news.uni-ulm.de!rz.uni-karlsruhe.de!rzstud1.rz.uni-karlsruhe.de!ule3
Newsgroups: news.software.readers
Organization: University of Karlsruhe, Germany
Lines: 140
NNTP-Posting-Host: rzstud1.rz.uni-karlsruhe.de
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: TIN [version 1.2 PL2]