- pid_t child_id;
- int i, status;
- char fold[BUFSIZ];
-
- if (verbose)
- printf("%sFcc: %s\n", msgstate == resent ? "Resent-" : "",
- folder);
- fflush(stdout);
-
- for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
- sleep(5);
- switch (child_id) {
- case NOTOK:
- if (verbose) {
- printf("Sorry man, but we had no more forks.\n");
- } else {
- fprintf(stderr, "Skipped %sFcc %s: unable to fork.\n",
- msgstate == resent ? "Resent-" : "",
- folder);
- }
- break;
-
- case OK:
- snprintf(fold, sizeof(fold), "%s%s",
- *folder == '+' || *folder == '@' ? "" : "+",
- folder);
- execlp(fileproc, mhbasename(fileproc),
- "-link", "-file", file, fold, NULL);
- _exit(-1);
-
- default:
- if ((status = pidwait(child_id, OK))) {
- if (verbose) {
- printf(" errored (0%o)\n", status);
- } else {
- fprintf(stderr, " %sFcc %s: errored (0%o)\n",
- msgstate == resent ?
- "Resent-" : "", folder,
- status);
- }
+ char *bccdraft = NULL;
+ char buf[BUFSIZ];
+ struct mailname *mp = NULL;
+ FILE *out = NULL;
+
+ for (mp=bccs; mp; mp=mp->m_next) {
+ /*
+ ** Note: This draft file will be left existing by send(1),
+ ** although renamed with backup prefix.
+ ** TODO: We should have it removed eventually.
+ */
+ bccdraft = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
+ fprintf(out, "To: %s\n", mp->m_text);
+ fprintf(out, "Subject: [BCC] %s", subject ? subject : "");
+ fprintf(out, "%s: %s\n", attach_hdr, origmsg);
+ fprintf(out, "------------\n");
+ fclose(out);
+
+ snprintf(buf, sizeof buf, "send%s %s",
+ pushflg ? " -push" : "", bccdraft);
+ if (system(buf) != 0) {
+ admonish(invo_name, "Problems to send Bcc to %s",
+ mp->m_text);
+ unlink(bccdraft);