home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / mail / sendmail / 2195 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.8 KB  |  64 lines

  1. Newsgroups: comp.mail.sendmail
  2. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!barsoom!barsoom!tih
  3. From: tih@barsoom.nhh.no (Tom Ivar Helbekkmo)
  4. Subject: Re: Removing msg body in IDA for postmaster
  5. Message-ID: <tih.715504703@barsoom>
  6. Sender: news@barsoom.nhh.no (USENET News System)
  7. Organization: Norwegian School of Economics
  8. References: <root.715272995@merlin> <1992Sep2.074845.9955@panix.com>
  9. Date: Thu, 3 Sep 1992 07:18:23 GMT
  10. Lines: 52
  11.  
  12. alexis@panix.com (Alexis Rosen) writes:
  13.  
  14. >2) Pipe it through a sed which chops it at the first blank line, then forwards
  15. >   it to postmaster.
  16.  
  17. The following is done in C, but performs basically the same function.
  18. I've been using this for a long time, as the alias expansion of
  19. MAIL-ERRORS, which is the CC address for bounces.  What I do here is
  20. extract just the header of the failed message, so that I can quickly
  21. scan over it and see if it *should* have worked.  If so, I contact the
  22. user in question to find out more.
  23.  
  24. #include <stdio.h>
  25.  
  26. int main(int argc, char **argv) {
  27.     char linebuf[512];
  28.     FILE *mpipe;
  29.     int done = 0;
  30.  
  31.     mpipe = popen("/usr/ucb/mail -s \"Mailer Error Report\" Postmaster", "w");
  32.  
  33.     while ((!done) && (!feof(stdin))) {
  34.     gets(linebuf);
  35.     if (strstr(linebuf, "Unsent message follows")) {
  36.         fprintf(mpipe,
  37.             "   ----- Header of unsent message follows  -----\n");
  38.         done = 1;
  39.     } else {
  40.         fprintf(mpipe, "%s\n", linebuf);
  41.     }
  42.     }
  43.     done = 0;
  44.     while ((!done) && (!feof(stdin))) {
  45.     gets(linebuf);
  46.     if (strlen(linebuf) == 0) {
  47.         fprintf(mpipe,
  48.             "\n   ----- Message body removed for privacy  -----\n");
  49.         done = 1;
  50.     } else {
  51.         fprintf(mpipe, "%s\n", linebuf);
  52.     }
  53.     }
  54.  
  55.     fclose(mpipe);
  56.  
  57.     return(0);
  58. }
  59.  
  60. -tih
  61. --
  62. Tom Ivar Helbekkmo, NHH, Bergen, Norway.  Telephone: +47-5-959205
  63. Postmaster for domain nhh.no.   Internet mail: tih@barsoom.nhh.no
  64.