2 * Display the outbound SMTP queue
8 * display one message in the queue
10 void display_queue_msg(long msgnum)
15 int is_delivery_list = 0;
18 time_t last_attempt = 0;
19 int number_of_attempts = 0;
21 char recipients[65536];
22 int recipients_len = 0;
31 strcpy(recipients, "");
34 serv_printf("MSG2 %ld", msgnum);
35 serv_getln(buf, sizeof buf);
36 if (buf[0] != '1') return;
38 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
40 if (!IsEmptyStr(buf)) {
42 if (buf[len - 1] == 13) {
47 if ( (IsEmptyStr(buf)) && (in_body == 0) ) {
52 && (!strncasecmp(buf, "Content-type: application/x-citadel-delivery-list", 49))
57 if ( (in_body) && (!is_delivery_list) ) {
58 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
59 /* Not a delivery list; flush and return quietly. */
64 if ( (in_body) && (is_delivery_list) ) {
65 extract_token(keyword, buf, 0, '|', sizeof keyword);
67 if (!strcasecmp(keyword, "msgid")) {
68 msgid = extract_long(buf, 1);
71 if (!strcasecmp(keyword, "submitted")) {
72 submitted = extract_long(buf, 1);
75 if (!strcasecmp(keyword, "attempted")) {
76 attempted = extract_long(buf, 1);
78 if (attempted > last_attempt) {
79 last_attempt = attempted;
83 if (!strcasecmp(keyword, "bounceto")) {
85 extract_token(sender, buf, 1, '|', sizeof sender);
87 /* Strip off local hostname if it's our own */
88 atsign = strchr(sender, '@');
91 if (!strcasecmp(atsign, ChrPtr(WC->serv_info->serv_nodename))) {
98 if (!strcasecmp(keyword, "remote")) {
101 extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
102 extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
104 if (!IsEmptyStr(thisrecp)) {
105 stresc(thismsg, sizeof thismsg, thisrecp, 1, 1);
106 if (!IsEmptyStr(thisdsn)) {
107 strcat(thismsg, "<br /> <i>");
108 stresc(&thismsg[strlen(thismsg)], sizeof thismsg,
110 strcat(thismsg, "</i>");
112 thismsg_len = strlen(thismsg);
114 if ((recipients_len + thismsg_len + 100) < sizeof recipients) {
115 if (!IsEmptyStr(recipients)) {
116 strcpy(&recipients[recipients_len], "<br />");
119 strcpy(&recipients[recipients_len], thismsg);
120 recipients_len += thismsg_len;
130 wc_printf("<tr><td>");
131 wc_printf("%ld<br />", msgnum);
132 wc_printf(" <a href=\"javascript:DeleteSMTPqueueMsg(%ld,%ld);\">%s</a>",
133 msgnum, msgid, _("(Delete)")
136 wc_printf("</td><td>");
138 webcit_fmt_date(buf, 1024, submitted, 1);
139 wc_printf("%s", buf);
145 wc_printf("</td><td>");
146 if (last_attempt > 0) {
147 webcit_fmt_date(buf, 1024, last_attempt, 1);
148 wc_printf("%s", buf);
154 wc_printf("</td><td>");
157 wc_printf("</td><td>");
158 wc_printf("%s", recipients);
159 wc_printf("</td></tr>\n");
164 void display_smtpqueue_inner_div(void) {
165 message_summary *Msg = NULL;
170 SharedMessageStatus Stat;
172 memset(&Stat, 0, sizeof(SharedMessageStatus));
173 /* Check to see if we can go to the __CitadelSMTPspoolout__ room.
174 * If not, we don't have access to the queue.
176 Buf = NewStrBufPlain(HKEY("__CitadelSMTPspoolout__"));
179 if (!strcasecmp(ChrPtr(WCC->CurRoom.name), "__CitadelSMTPspoolout__")) {
181 Stat.maxload = 10000;
182 Stat.lowest_found = (-1);
183 Stat.highest_found = (-1);
184 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
186 wc_printf("<table class=\"mailbox_summary\" rules=rows "
187 "cellpadding=2 style=\"width:100%%;\">"
190 wc_printf("<tr><td><b><i>");
191 wc_printf(_("Message ID"));
192 wc_printf("</i></b></td><td><b><i>");
193 wc_printf(_("Date/time submitted"));
194 wc_printf("</i></b></td><td><b><i>");
195 wc_printf(_("Last attempt"));
196 wc_printf("</i></b></td><td><b><i>");
197 wc_printf(_("Sender"));
198 wc_printf("</i></b></td><td><b><i>");
199 wc_printf(_("Recipients"));
200 wc_printf("</i></b></td></tr>\n");
202 for (i=0; (i < num_msgs) && (i < Stat.maxload); ++i) {
203 Msg = GetMessagePtrAt(i, WCC->summ);
205 display_queue_msg(Msg->msgnum);
209 wc_printf("</table>");
213 wc_printf("<br /><br /><div align=\"center\">");
214 wc_printf(_("The queue is empty."));
215 wc_printf("</div><br /><br />");
219 wc_printf("<br /><br /><div align=\"center\">");
220 wc_printf(_("You do not have permission to view this resource."));
221 wc_printf("</div><br /><br />");
223 output_headers(0, 0, 0, 0, 0, 0);
228 * display the outbound SMTP queue
230 void display_smtpqueue(void)
232 output_headers(1, 1, 2, 0, 0, 0);
234 wc_printf("<div id=\"banner\">\n");
236 wc_printf(_("View the outbound SMTP queue"));
237 wc_printf("</h1>\n");
238 wc_printf("</div>\n");
240 wc_printf("<div id=\"content\" class=\"service\">\n");
242 wc_printf("<table class=\"smtpqueue_background\">"
243 "<tr><td valign=top>\n");
245 wc_printf("<div id=\"smtpqueue_inner_div\">"
246 "<div align=\"center\"><img src=\"static/throbber.gif\"></div>"
248 "<div align=\"center\">"
249 "<a href=\"javascript:RefreshSMTPqueueDisplay();\">%s</a>"
251 "</td></tr></table>\n", _("Refresh this page")
254 StrBufAppendPrintf(WC->trailing_javascript, "RefreshSMTPqueueDisplay();\n");
261 InitModule_SMTP_QUEUE
264 WebcitAddUrlHandler(HKEY("display_smtpqueue"), "", 0, display_smtpqueue, 0);
265 WebcitAddUrlHandler(HKEY("display_smtpqueue_inner_div"), "", 0, display_smtpqueue_inner_div, 0);