5 * \defgroup SMTPqueue Display the outbound SMTP queue
6 * \ingroup CitadelConfig
12 * \brief display one message in the queue
14 void display_queue_msg(long msgnum)
19 int is_delivery_list = 0;
22 time_t last_attempt = 0;
23 int number_of_attempts = 0;
25 char recipients[65536];
32 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) == 0) && (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")) {
84 extract_token(sender, buf, 1, '|', sizeof sender);
86 /* Strip off local hostname if it's our own */
88 atsign = strchr(sender, '@');
91 if (!strcasecmp(atsign, serv_info.serv_nodename)) {
98 if (!strcasecmp(keyword, "remote")) {
99 extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
100 extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
102 if (strlen(recipients) + strlen(thisrecp) + strlen(thisdsn) + 100
103 < sizeof recipients) {
104 if (!IsEmptyStr(recipients)) {
105 strcat(recipients, "<br />");
107 stresc(&recipients[strlen(recipients)], thisrecp, 1, 1);
108 strcat(recipients, "<br /> <i>");
109 stresc(&recipients[strlen(recipients)], thisdsn, 1, 1);
110 strcat(recipients, "</i>");
120 wprintf("%ld<br />", msgnum);
121 wprintf(" <a href=\"javascript:DeleteQueueMsg(%ld,%ld);\">%s</a>",
122 msgnum, msgid, _("(Delete)")
125 wprintf("</td><td>");
127 fmt_date(buf, submitted, 1);
134 wprintf("</td><td>");
135 if (last_attempt > 0) {
136 fmt_date(buf, last_attempt, 1);
143 wprintf("</td><td>");
146 wprintf("</td><td>");
147 wprintf("%s", recipients);
148 wprintf("</td></tr>\n");
153 void display_smtpqueue_inner_div(void) {
157 /* Check to see if we can go to the __CitadelSMTPspoolout__ room.
158 * If not, we don't have access to the queue.
160 gotoroom("__CitadelSMTPspoolout__");
161 if (!strcasecmp(WC->wc_roomname, "__CitadelSMTPspoolout__")) {
163 num_msgs = load_msg_ptrs("MSGS ALL", 0);
165 wprintf("<table class=\"mailbox_summary\" rules=rows "
166 "cellpadding=2 style=\"width:100%%;-moz-user-select:none;\">"
169 wprintf("<tr><td><b><i>");
170 wprintf(_("Message ID"));
171 wprintf("</i></b></td><td><b><i>");
172 wprintf(_("Date/time submitted"));
173 wprintf("</i></b></td><td><b><i>");
174 wprintf(_("Last attempt"));
175 wprintf("</i></b></td><td><b><i>");
176 wprintf(_("Sender"));
177 wprintf("</i></b></td><td><b><i>");
178 wprintf(_("Recipients"));
179 wprintf("</i></b></td></tr>\n");
181 for (i=0; i<num_msgs; ++i) {
182 display_queue_msg(WC->msgarr[i]);
189 wprintf("<br /><br /><div align=\"center\">");
190 wprintf(_("The queue is empty."));
191 wprintf("</div><br /><br />");
195 wprintf("<br /><br /><div align=\"center\">");
196 wprintf(_("You do not have permission to view this resource."));
197 wprintf("</div><br /><br />");
203 * \brief display the outbound SMTP queue
205 void display_smtpqueue(void)
207 output_headers(1, 1, 2, 0, 0, 0);
209 wprintf("<script type=\"text/javascript\"> \n"
210 "function RefreshQueueDisplay() { \n"
211 " new Ajax.Updater('smtpqueue_inner_div', \n"
212 " 'display_smtpqueue_inner_div', { method: 'get', \n"
213 " parameters: Math.random() } ); \n"
216 "function DeleteQueueMsg(msgnum1, msgnum2) { \n"
217 " new Ajax.Request( \n"
218 " 'ajax_servcmd', { \n"
219 " method: 'post', \n"
220 " parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2, \n"
221 " onComplete: RefreshQueueDisplay() \n"
229 wprintf("<div id=\"banner\">\n");
231 wprintf(_("View the outbound SMTP queue"));
235 wprintf("<div id=\"content\" class=\"service\">\n");
237 wprintf("<div class=\"fix_scrollbar_bug\">"
238 "<table class=\"smtpqueue_background\">"
239 "<tr><td valign=top>\n");
241 wprintf("<div id=\"smtpqueue_inner_div\">");
243 display_smtpqueue_inner_div();
246 "<div align=\"center\">"
247 "<a href=\"javascript:RefreshQueueDisplay();\">%s</a>"
249 "</td></tr></table></div>\n", _("Refresh this page")