1 /*++
2 /* NAME
3 /*	qmgr_bounce
4 /* SUMMARY
5 /*	deal with mail that will not be delivered
6 /* SYNOPSIS
7 /*	#include "qmgr.h"
8 /*
9 /*	QMGR_QUEUE *qmgr_bounce_recipient(message, recipient, dsn)
10 /*	QMGR_MESSAGE *message;
11 /*	RECIPIENT *recipient;
12 /*	DSN	*dsn;
13 /* DESCRIPTION
14 /*	qmgr_bounce_recipient() produces a bounce log record.
15 /*	Once the bounce record is written successfully, the recipient
16 /*	is marked as done. When the bounce record cannot be written,
17 /*	the message structure is updated to reflect that the mail is
18 /*	deferred.
19 /*
20 /*	Arguments:
21 /* .IP message
22 /*	Open queue file with the message being bounced.
23 /* .IP recipient
24 /*	The recipient that will not be delivered.
25 /* .IP dsn
26 /*	Delivery status information. See dsn(3).
27 /* DIAGNOSTICS
28 /*	Panic: consistency check failure. Fatal: out of memory.
29 /* LICENSE
30 /* .ad
31 /* .fi
32 /*	The Secure Mailer license must be distributed with this software.
33 /* AUTHOR(S)
34 /*	Wietse Venema
35 /*	IBM T.J. Watson Research
36 /*	P.O. Box 704
37 /*	Yorktown Heights, NY 10598, USA
38 /*--*/
39 
40 /* System library. */
41 
42 #include <sys_defs.h>
43 
44 /* Utility library. */
45 
46 /* Global library. */
47 
48 #include <bounce.h>
49 #include <deliver_completed.h>
50 
51 /* Application-specific. */
52 
53 #include "qmgr.h"
54 
55 /* qmgr_bounce_recipient - bounce one message recipient */
56 
qmgr_bounce_recipient(QMGR_MESSAGE * message,RECIPIENT * recipient,DSN * dsn)57 void    qmgr_bounce_recipient(QMGR_MESSAGE *message, RECIPIENT *recipient,
58 			              DSN *dsn)
59 {
60     MSG_STATS stats;
61     int     status;
62 
63     status = bounce_append(message->tflags, message->queue_id,
64 			   QMGR_MSG_STATS(&stats, message), recipient,
65 			   "none", dsn);
66 
67     if (status == 0)
68 	deliver_completed(message->fp, recipient->offset);
69     else
70 	message->flags |= status;
71 }
72