- /*
- ** If mailing back, do it.
- ** Throw away all further output. Don't do aliases, since
- ** this could cause loops, e.g., if joe mails to x:joe,
- ** and for some reason the network for x: is down, then
- ** the response gets sent to x:joe, which gives a
- ** response, etc. Also force the mail to be delivered
- ** even if a version of it has already been sent to the
- ** sender.
- */
+ state = state == ESM_MAIL ? ESM_POSTMASTER : ESM_USRTMP;
+ break;
+
+ case ESM_DEADLETTER:
+ /*
+ ** Save the message in dead.letter.
+ ** If we weren't mailing back, and the user is
+ ** local, we should save the message in
+ ** ~/dead.letter so that the poor person doesn't
+ ** have to type it over again -- and we all know
+ ** what poor typists UNIX users are.
+ */
+
+ p = NULL;
+ if (e->e_from.q_mailer == LocalMailer)
+ {
+ if (e->e_from.q_home != NULL)
+ p = e->e_from.q_home;
+ else if ((pw = getpwnam(e->e_from.q_user)) != NULL)
+ p = pw->pw_dir;
+ }
+ if (p == NULL)
+ {
+ syserr("Can't return mail to %s", e->e_from.q_paddr);
+ state = ESM_MAIL;
+ break;
+ }
+ if (e->e_dfp != NULL)
+ {
+ auto ADDRESS *q;
+ bool oldverb = Verbose;
+
+ /* we have a home directory; open dead.letter */
+ define('z', p, e);
+ expand("\001z/dead.letter", buf, &buf[sizeof buf - 1], e);
+ Verbose = TRUE;
+ message(Arpa_Info, "Saving message in %s", buf);
+ Verbose = oldverb;
+ e->e_to = buf;
+ q = NULL;
+ sendtolist(buf, (ADDRESS *) NULL, &q);
+ if (deliver(e, q) == 0)
+ state = ESM_DONE;
+ else
+ state = ESM_MAIL;
+ }
+ break;