14 /* send messae adding our own reply-to and precedence */
20 for(f = firstfield; f; f = f->next){
21 if(f->node->c == FROM && from == nil)
22 from = getaddr(f->node);
23 if(f->node->c == SENDER && sender == nil)
24 sender = getaddr(f->node);
28 /* write address file, should be append only */
30 writeaddr(char *file, char *addr, int rem, char *listname)
35 fd = open(file, OWRITE);
37 fd = create(file, OWRITE, DMAPPEND|0666);
39 sysfatal("creating address list %s: %r", file);
41 nd.mode = DMAPPEND|0666;
46 fprint(fd, "!%s\n", addr);
48 fprint(fd, "%s\n", addr);
52 sendnotification(addr, listname, rem);
61 for(l = &al; *l; l = &(*l)->next){
63 if(strcmp(addr, a->addr) == 0){
78 for(l = &al; *l; l = &(*l)->next){
79 if(strcmp(addr, (*l)->addr) == 0)
83 *l = a = malloc(sizeof(*a)+strlen(addr)+1);
85 sysfatal("allocating: %r");
86 a->addr = (char*)&a[1];
87 strcpy(a->addr, addr);
93 /* read address file */
100 b = Bopen(file, OREAD);
104 while((p = Brdline(b, '\n')) != nil){
105 p[Blinelen(b)-1] = 0;
116 /* start a mailer sending to all the receivers */
118 startmailer(char *name)
125 putenv("upasname", "/dev/null");
127 sysfatal("creating pipe: %r");
130 sysfatal("starting mailer: %r");
142 av = malloc(sizeof(char*)*(na+2));
144 sysfatal("starting mailer: %r");
147 for(a = al; a != nil; a = a->next)
150 exec("/bin/upas/send", av);
151 sysfatal("execing mailer: %r");
158 sendnotification(char *addr, char *listname, int rem)
163 putenv("upasname", "/dev/null");
165 sysfatal("creating pipe: %r");
168 sysfatal("starting mailer: %r");
173 execl("/bin/upas/send", "mlnotify", addr, nil);
174 sysfatal("execing mailer: %r");
178 fprint(pfd[1], "From: %s-owner\n\n", listname);
180 fprint(pfd[1], "You have removed from the %s mailing list\n", listname);
182 fprint(pfd[1], "You have been added to the %s mailing list\n", listname);
183 fprint(pfd[1], "To be removed, send an email to %s-owner containing\n",
185 fprint(pfd[1], "the word 'remove' in the subject or body.\n");
189 /* wait for mailer to end */
191 if(w->msg != nil && w->msg[0])
192 sysfatal("%s", w->msg);