1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*	from OpenSolaris "mta_ercode.c	1.7	05/06/08 SMI"	*/
27 
28 /*
29  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
30  *
31  * Sccsid @(#)mta_ercode.c	1.3 (gritter) 6/18/05
32  */
33 	 	/* SVr4.0 2.	*/
34 #include "mail.h"
35 /*
36  * Map mail(1) error into MTA reason-codes for negative delivery notification.
37  */
38 static char *MTAerrors[] = {
39 		"",
40 /*  1 */	"Invalid Address Specification",
41 /*  2 */	"Ambiguous Originator/Recipient Name",
42 /*  3 */	"Message Transfer Agent Congestion",
43 /*  4 */	"Loop Detection",
44 /*  5 */	"Unavailable User Agent",
45 /*  6 */	"Expired Maximum Time",
46 /*  7 */	"Unsupported Encoded Information Types",
47 /*  8 */	"Prohibited Conversion",
48 /*  9 */	"Impractical Conversion",
49 /* 10 */	"Invalid Parameters",
50 /* 11 */	"Transfer Failure",
51 /* 12 */	"Inability To Transfer",
52 /* 13 */	"Conversion Not Performed",
53 /* 14 */	"Deferred Delivery Not Available",
54 /* 15 */	"Too many Recipients",
55 /* 16 */	"Mail Too Large For Destination To Receive"
56 };
57 
58 void
mta_ercode(FILE * outfile)59 mta_ercode(FILE *outfile)
60 {
61 	register int mtacode;
62 	switch (error) {
63 	case E_FROM:	/* too many From lines */
64 		mtacode = 1;
65 		break;
66 
67 	case E_SNDR:	/* invalid sender */
68 	case E_USER:	/* invalid user */
69 		mtacode = 2;
70 		break;
71 
72 	case E_FRWL:	/* forwarding loop */
73 	case E_UNBND:	/* Unbounded forwarding */
74 		mtacode = 4;
75 		break;
76 
77 	case 23:	/* disallowed from sending binary to remote */
78 		mtacode = 7;
79 		break;
80 
81 	case E_SYNTAX:	/* syntax error */
82 	default:
83 		mtacode = 10;
84 		break;
85 
86 	case E_SURG:	/* surrogate command failed - rc != 0 || 99 */
87 		mtacode = 11;
88 		break;
89 
90 	case E_REMOTE:	/* unknown remote */
91 	case E_FILE:	/* file error */
92 	case E_FRWD:	/* cannot forward */
93 	case E_PERM:	/* bad permissions */
94 	case E_TMP:	/* temporary file problem */
95 	case E_DEAD:	/* Cannot create dead.letter */
96 	case E_LOCK:	/* cannot create lock file */
97 	case E_GROUP:	/* no group id of 'mail' */
98 	case E_MEM:	/* malloc failure */
99 	case E_FORK:	/* could not fork */
100 	case E_PIPE:	/* could not pipe */
101 	case E_OWNR:	/* invoker does not own mailfile */
102 	case E_DENY:	/* permission denied by mailsurr file */
103 		mtacode = 12;
104 		break;
105 
106 	case E_MBOX:	/* mbox problem */
107 		mtacode = 12;
108 		if (sav_errno != EFBIG) {
109 			break;
110 		}
111 		/* Note drop-thru... */
112 	case E_SPACE:	/* no space */
113 		mtacode = 16;
114 		break;
115 	}
116 	fprintf(outfile, "%.2d  %s\n", mtacode, MTAerrors[mtacode]);
117 }
118