- * Change the "X-Envelope-From:" field
- * (if first line) back to "From ".
- */
- char tmpbuffer[BUFSIZ];
- char *ep;
-
- strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
- ep = tmpbuffer + 17;
- snprintf (buffer, sizeof(buffer), "From %s", ep);
- } else if (strncmp (buffer, "From ", 5)) {
- /*
- * If there is already a "From " line,
- * then leave it alone. Else we add one.
- */
- char tmpbuffer[BUFSIZ];
- char *tp, *ep;
-
- strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
- ep = "nobody@nowhere";
- tp = dctime(dlocaltimenow());
- snprintf (buffer, sizeof(buffer), "From %s %s%s", ep, tp, tmpbuffer);
- }
- }
+ ** Check the first line, and make some changes.
+ */
+ if (j == 0 && !text) {
+ /*
+ ** Change the "Return-Path:" field
+ ** (if in first line) back to "From ".
+ */
+ if (strncmp(buffer, "Return-Path:", 12)==0) {
+ char tmpbuffer[BUFSIZ];
+ char *tp, *ep, *fp;
+
+ strncpy(tmpbuffer, buffer,
+ sizeof(tmpbuffer));
+ ep = tmpbuffer + 13;
+ if (!(fp = strchr(ep + 1, ' ')))
+ fp = strchr(ep + 1, '\n');
+ tp = dctime(dlocaltimenow());
+ snprintf(buffer, sizeof(buffer), "From %.*s %s", (int)(fp - ep), ep, tp);
+ } else if (strncmp(buffer, "X-Envelope-From:",
+ 16)==0) {
+ /*
+ ** Change the "X-Envelope-From:"
+ ** field (if first line) back
+ ** to "From ".
+ */
+ char tmpbuffer[BUFSIZ];
+ char *ep;
+
+ strncpy(tmpbuffer, buffer,
+ sizeof(tmpbuffer));
+ ep = tmpbuffer + 17;
+ snprintf(buffer, sizeof(buffer),
+ "From %s", ep);
+ } else if (strncmp(buffer, "From ", 5)!=0) {
+ /*
+ ** If there is already a "From "
+ ** line, then leave it alone.
+ ** Else we add one.
+ */
+ char tmpbuffer[BUFSIZ];
+ char *tp, *ep;
+
+ strncpy(tmpbuffer, buffer,
+ sizeof(tmpbuffer));
+ ep = "nobody@nowhere";
+ tp = dctime(dlocaltimenow());
+ snprintf(buffer, sizeof(buffer),
+ "From %s %s%s",
+ ep, tp, tmpbuffer);
+ }
+ }