Program for maintaining mailing lists (sendmail).
Stephen J. Muir
stephen at dcl-cs.UUCP
Wed Aug 7 10:45:34 AEST 1985
I wanted to maintain large mailing lists using "sendmail". I only knew of two
ways of doing this:
- set up a login name with a ".forward" file
OR
- set up aliases in "/usr/lib/aliases"
I didn't want to set up login names and "/usr/lib/aliases" would have become
too unwieldy, so I wrote another program to do it and this follows. If there
is another way to do it, or there is a better program about, please mail me.
Installation:
Compile the following program and put in "/usr/bin/maillistfile". Create a
file containing all the mailboxes in the list, one per line. Put an entry of
the following form in "/usr/lib/aliases":
fire-lovers:"|maillistfile /usr/gurus/elton/fire-lovers".
----------------------------------- cut here ----------------------------------
#!/bin/sh
echo 'Start of pack.out, part 01 of 01:'
echo 'x - maillistfile.c'
sed 's/^X//' > maillistfile.c << '/'
X/* Written by Stephen J. Muir, Computing Dept., Lancaster University */
X
X# include <sys/types.h>
X# include <sys/stat.h>
X# include <sys/file.h>
X# include <stdio.h>
X
Xextern char *malloc ();
X
Xchar *mailer = "/usr/lib/sendmail", **newargv, **nargvp;
X
Xint fd, count;
X
Xstruct stat stat;
X
Xmain (argc, argv, envp)
X char *argv [], *envp [];
X { register char *cp, *recipients;
X if (argc != 2)
X { fprintf (stderr, "usage: maillistfile file\n");
X exit (1);
X }
X if ((fd = open (argv [1], O_RDONLY, 0)) == -1)
X { perror (argv [1]);
X exit (1);
X }
X setuid (getuid ());
X (void)fstat (fd, &stat);
X if ((stat.st_mode & S_IFMT) != S_IFREG)
X { fprintf (stderr, "%s: not a regular file", argv [1]);
X exit (1);
X }
X if ((recipients = malloc (stat.st_size)) == 0)
X { fprintf (stderr, "Out of memory.\n");
X exit (1);
X }
X if (read (fd, recipients, stat.st_size) != stat.st_size)
X { perror ("read()");
X exit (1);
X }
X for (cp = recipients; cp < recipients + stat.st_size; ++cp)
X if (*cp == '\0')
X { fprintf (stderr, "%s: null byte in file\n", argv [1]);
X exit (1);
X }
X else if (*cp == '\n')
X { *cp = '\0';
X ++count;
X }
X if (*--cp != '\0')
X { fprintf (stderr, "%s: incomplete last line\n", argv [1]);
X exit (1);
X }
X if (count == 0)
X { fprintf (stderr, "%s: empty list\n", argv [1]);
X exit (1);
X }
X if ((nargvp =
X newargv =
X (char **)malloc ((sizeof (char **)) * (count + 3))
X ) == 0
X )
X { fprintf (stderr, "Out of memory.\n");
X exit (1);
X }
X *nargvp++ = "maillist";
X *nargvp++ = "-oMslist-channel";
X cp = recipients;
X while (count--)
X { *nargvp++ = cp;
X while (*cp++ != '\0');
X }
X *nargvp++ = 0;
X execve (mailer, newargv, envp);
X perror (mailer);
X exit (1);
X }
/
echo 'Part 01 of pack.out complete.'
exit
--
UUCP: ...!seismo!mcvax!ukc!dcl-cs!stephen
DARPA: stephen%lancs.comp at ucl-cs | Post: University of Lancaster,
JANET: stephen at uk.ac.lancs.comp | Department of Computing,
Phone: +44 524 65201 Ext. 4599 | Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution | LA1 4YR
More information about the Comp.sources.unix
mailing list