4 * Display the outbound SMTP queue
10 * display one message in the queue
12 void display_queue_msg(long msgnum)
17 int is_delivery_list = 0;
20 time_t last_attempt = 0;
21 int number_of_attempts = 0;
23 char recipients[65536];
24 int recipients_len = 0;
33 strcpy(recipients, "");
36 serv_printf("MSG2 %ld", msgnum);
37 serv_getln(buf, sizeof buf);
38 if (buf[0] != '1') return;
40 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
42 if (!IsEmptyStr(buf)) {
44 if (buf[len - 1] == 13) {
49 if ( (IsEmptyStr(buf)) && (in_body == 0) ) {
54 && (!strncasecmp(buf, "Content-type: application/x-citadel-delivery-list", 49))
59 if ( (in_body) && (!is_delivery_list) ) {
60 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
61 /* Not a delivery list; flush and return quietly. */
66 if ( (in_body) && (is_delivery_list) ) {
67 extract_token(keyword, buf, 0, '|', sizeof keyword);
69 if (!strcasecmp(keyword, "msgid")) {
70 msgid = extract_long(buf, 1);
73 if (!strcasecmp(keyword, "submitted")) {
74 submitted = extract_long(buf, 1);
77 if (!strcasecmp(keyword, "attempted")) {
78 attempted = extract_long(buf, 1);
80 if (attempted > last_attempt) {
81 last_attempt = attempted;
85 if (!strcasecmp(keyword, "bounceto")) {
87 extract_token(sender, buf, 1, '|', sizeof sender);
89 /* Strip off local hostname if it's our own */
90 atsign = strchr(sender, '@');
93 if (!strcasecmp(atsign, serv_info.serv_nodename)) {
100 if (!strcasecmp(keyword, "remote")) {
103 extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
104 extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
106 if (!IsEmptyStr(thisrecp)) {
107 stresc(thismsg, sizeof thismsg, thisrecp, 1, 1);
108 if (!IsEmptyStr(thisdsn)) {
109 strcat(thismsg, "<br /> <i>");
110 stresc(&thismsg[strlen(thismsg)], sizeof thismsg,
112 strcat(thismsg, "</i>");
114 thismsg_len = strlen(thismsg);
116 if ((recipients_len + thismsg_len + 100) < sizeof recipients) {
117 if (!IsEmptyStr(recipients)) {
118 strcpy(&recipients[recipients_len], "<br />");
121 strcpy(&recipients[recipients_len], thismsg);
122 recipients_len += thismsg_len;
133 wprintf("%ld<br />", msgnum);
134 wprintf(" <a href=\"javascript:DeleteQueueMsg(%ld,%ld);\">%s</a>",
135 msgnum, msgid, _("(Delete)")
138 wprintf("</td><td>");
140 webcit_fmt_date(buf, submitted, 1);
147 wprintf("</td><td>");
148 if (last_attempt > 0) {
149 webcit_fmt_date(buf, last_attempt, 1);
156 wprintf("</td><td>");
159 wprintf("</td><td>");
160 wprintf("%s", recipients);
161 wprintf("</td></tr>\n");
166 void display_smtpqueue_inner_div(void) {
167 message_summary *Msg;
172 /* Check to see if we can go to the __CitadelSMTPspoolout__ room.
173 * If not, we don't have access to the queue.
175 gotoroom("__CitadelSMTPspoolout__");
176 if (!strcasecmp(WCC->wc_roomname, "__CitadelSMTPspoolout__")) {
178 num_msgs = load_msg_ptrs("MSGS ALL", 0);
180 wprintf("<table class=\"mailbox_summary\" rules=rows "
181 "cellpadding=2 style=\"width:100%%;\">"
184 wprintf("<tr><td><b><i>");
185 wprintf(_("Message ID"));
186 wprintf("</i></b></td><td><b><i>");
187 wprintf(_("Date/time submitted"));
188 wprintf("</i></b></td><td><b><i>");
189 wprintf(_("Last attempt"));
190 wprintf("</i></b></td><td><b><i>");
191 wprintf(_("Sender"));
192 wprintf("</i></b></td><td><b><i>");
193 wprintf(_("Recipients"));
194 wprintf("</i></b></td></tr>\n");
196 for (i=0; i<num_msgs; ++i) {
197 Msg = GetMessagePtrAt(i, WCC->summ);
199 display_queue_msg((Msg==NULL)? 0 : Msg->msgnum);
206 wprintf("<br /><br /><div align=\"center\">");
207 wprintf(_("The queue is empty."));
208 wprintf("</div><br /><br />");
212 wprintf("<br /><br /><div align=\"center\">");
213 wprintf(_("You do not have permission to view this resource."));
214 wprintf("</div><br /><br />");
220 * \brief display the outbound SMTP queue
222 void display_smtpqueue(void)
224 output_headers(1, 1, 2, 0, 0, 0);
226 wprintf("<script type=\"text/javascript\"> \n"
227 "function RefreshQueueDisplay() { \n"
228 " new Ajax.Updater('smtpqueue_inner_div', \n"
229 " 'display_smtpqueue_inner_div', { method: 'get', \n"
230 " parameters: Math.random() } ); \n"
233 "function DeleteQueueMsg(msgnum1, msgnum2) { \n"
234 " new Ajax.Request( \n"
235 " 'ajax_servcmd', { \n"
236 " method: 'post', \n"
237 " parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2, \n"
238 " onComplete: RefreshQueueDisplay() \n"
246 wprintf("<div id=\"banner\">\n");
248 wprintf(_("View the outbound SMTP queue"));
252 wprintf("<div id=\"content\" class=\"service\">\n");
254 wprintf("<div class=\"fix_scrollbar_bug\">"
255 "<table class=\"smtpqueue_background\">"
256 "<tr><td valign=top>\n");
258 wprintf("<div id=\"smtpqueue_inner_div\">");
260 display_smtpqueue_inner_div();
263 "<div align=\"center\">"
264 "<a href=\"javascript:RefreshQueueDisplay();\">%s</a>"
266 "</td></tr></table></div>\n", _("Refresh this page")
273 InitModule_SMTP_QUEUE
276 WebcitAddUrlHandler(HKEY("display_smtpqueue"), display_smtpqueue, 0);
277 WebcitAddUrlHandler(HKEY("display_smtpqueue_inner_div"), display_smtpqueue_inner_div, 0);