xref: /illumos-gate/usr/src/cmd/mail/mta_ercode.c (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
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 #include "mail.h"
26 /*
27  * Map mail(1) error into MTA reason-codes for negative delivery notification.
28  */
29 static char *MTAerrors[] = {
30 		"",
31 /*  1 */	"Invalid Address Specification",
32 /*  2 */	"Ambiguous Originator/Recipient Name",
33 /*  3 */	"Message Transfer Agent Congestion",
34 /*  4 */	"Loop Detection",
35 /*  5 */	"Unavailable User Agent",
36 /*  6 */	"Expired Maximum Time",
37 /*  7 */	"Unsupported Encoded Information Types",
38 /*  8 */	"Prohibited Conversion",
39 /*  9 */	"Impractical Conversion",
40 /* 10 */	"Invalid Parameters",
41 /* 11 */	"Transfer Failure",
42 /* 12 */	"Inability To Transfer",
43 /* 13 */	"Conversion Not Performed",
44 /* 14 */	"Deferred Delivery Not Available",
45 /* 15 */	"Too many Recipients",
46 /* 16 */	"Mail Too Large For Destination To Receive"
47 };
48 
mta_ercode(outfile)49 void mta_ercode(outfile)
50 FILE *outfile;
51 {
52 	register int mtacode;
53 	switch (error) {
54 	case E_FROM:	/* too many From lines */
55 		mtacode = 1;
56 		break;
57 
58 	case E_SNDR:	/* invalid sender */
59 	case E_USER:	/* invalid user */
60 		mtacode = 2;
61 		break;
62 
63 	case E_FRWL:	/* forwarding loop */
64 	case E_UNBND:	/* Unbounded forwarding */
65 		mtacode = 4;
66 		break;
67 
68 	case 23:	/* disallowed from sending binary to remote */
69 		mtacode = 7;
70 		break;
71 
72 	case E_SYNTAX:	/* syntax error */
73 	default:
74 		mtacode = 10;
75 		break;
76 
77 	case E_SURG:	/* surrogate command failed - rc != 0 || 99 */
78 		mtacode = 11;
79 		break;
80 
81 	case E_REMOTE:	/* unknown remote */
82 	case E_FILE:	/* file error */
83 	case E_FRWD:	/* cannot forward */
84 	case E_PERM:	/* bad permissions */
85 	case E_TMP:	/* temporary file problem */
86 	case E_DEAD:	/* Cannot create dead.letter */
87 	case E_LOCK:	/* cannot create lock file */
88 	case E_GROUP:	/* no group id of 'mail' */
89 	case E_MEM:	/* malloc failure */
90 	case E_FORK:	/* could not fork */
91 	case E_PIPE:	/* could not pipe */
92 	case E_OWNR:	/* invoker does not own mailfile */
93 	case E_DENY:	/* permission denied by mailsurr file */
94 		mtacode = 12;
95 		break;
96 
97 	case E_MBOX:	/* mbox problem */
98 		mtacode = 12;
99 		if (sav_errno != EFBIG) {
100 			break;
101 		}
102 		/* Note drop-thru... */
103 	case E_SPACE:	/* no space */
104 		mtacode = 16;
105 		break;
106 	}
107 	fprintf(outfile, "%.2d  %s\n", mtacode, MTAerrors[mtacode]);
108 }
109