2 * etrn.c -- ETRN protocol methods
4 * For license terms, see the file COPYING in this directory.
13 static int etrn_ok (int sock, char *argbuf)
14 /* parse command response */
17 char buf [POPBUFSIZE+1];
20 if (ok == SM_UNRECOVERABLE)
26 static int etrn_getrange(int sock, struct query *ctl, int*countp, int*newp)
27 /* send ETRN and interpret the response */
30 char buf [POPBUFSIZE+1];
32 if ((ok = SMTP_ehlo(sock, ctl->server.names->id, &opts)))
34 error(0, 0, "%s's SMTP listener does not support ESMTP",
35 ctl->server.names->id);
38 else if (!(opts & ESMTP_ETRN))
40 error(0, 0, "%s's SMTP listener does not support ETRN",
41 ctl->server.names->id);
45 *countp = *newp = -1; /* make sure we don't enter the fetch loop */
47 /* ship the actual poll and get the response */
48 gen_send(sock, "ETRN %s", ctl->smtphost);
49 if (ok = gen_recv(sock, buf, sizeof(buf)))
52 /* this switch includes all the response codes described in RFC1985 */
55 case 250: /* OK, queuing for node <x> started */
56 error(0, 0, "Queuing for %s started", ctl->smtphost);
59 case 251: /* OK, no messages waiting for node <x> */
60 error(0, 0, "No messages waiting for %s", ctl->smtphost);
63 case 252: /* OK, pending messages for node <x> started */
64 case 253: /* OK, <n> pending messages for node <x> started */
65 error(0, 0, "Pending messages for %s started");
68 case 458: /* Unable to queue messages for node <x> */
69 error(0, -1, "Unable to queue messages for node %s", ctl->smtphost);
72 case 459: /* Node <x> not allowed: <reason> */
73 error(0, -1, "Node %s not allowed: %s", ctl->smtphost, buf);
76 case 500: /* Syntax Error */
77 error(0, -1, "ETRN syntax error");
80 case 501: /* Syntax Error in Parameters */
81 error(0, -1, "ETRN syntax error in parameters");
85 error(0, -1, "Unknown ETRN error %d", atoi(buf));
92 const static struct method etrn =
94 "ETRN", /* ESMTP ETRN extension */
95 25, /* standard SMTP port */
96 FALSE, /* this is not a tagged protocol */
97 FALSE, /* this does not use a message delimiter */
98 etrn_ok, /* parse command response */
99 NULL, /* no need to get authentication */
100 etrn_getrange, /* initialize message sending */
101 NULL, /* we cannot get a list of sizes */
102 NULL, /* how do we tell a message is old? */
103 NULL, /* request given message */
104 NULL, /* no message trailer */
105 NULL, /* how to delete a message */
106 "QUIT", /* the ETRN exit command */
109 int doETRN (struct query *ctl)
110 /* retrieve messages using ETRN */
113 fprintf(stderr, "Option --keep is not supported with ETRN\n");
117 fprintf(stderr, "Option --flush is not supported with ETRN\n");
121 fprintf(stderr, "Option --remote is not supported with ETRN\n");
125 fprintf(stderr, "Option --check is not supported with ETRN\n");
128 peek_capable = FALSE;
129 return(do_protocol(ctl, &etrn));
132 /* etrn.c ends here */