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];
31 strcpy(recipients, "");
33 serv_printf("MSG2 %ld", msgnum);
34 serv_getln(buf, sizeof buf);
35 if (buf[0] != '1') return;
37 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
39 if (strlen(buf) > 0) {
40 if (buf[strlen(buf)-1] == 13) {
41 buf[strlen(buf)-1] = 0;
45 if ( (strlen(buf) == 0) && (in_body == 0) ) {
50 && (!strncasecmp(buf, "Content-type: application/x-citadel-delivery-list", 49))
55 if ( (in_body) && (!is_delivery_list) ) {
56 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
57 /* Not a delivery list; flush and return quietly. */
62 if ( (in_body) && (is_delivery_list) ) {
63 extract_token(keyword, buf, 0, '|', sizeof keyword);
65 if (!strcasecmp(keyword, "msgid")) {
66 msgid = extract_long(buf, 1);
69 if (!strcasecmp(keyword, "submitted")) {
70 submitted = extract_long(buf, 1);
73 if (!strcasecmp(keyword, "attempted")) {
74 attempted = extract_long(buf, 1);
76 if (attempted > last_attempt) {
77 last_attempt = attempted;
81 if (!strcasecmp(keyword, "bounceto")) {
82 extract_token(sender, buf, 1, '|', sizeof sender);
84 /* Strip off local hostname if it's our own */
86 atsign = strchr(sender, '@');
89 if (!strcasecmp(atsign, serv_info.serv_nodename)) {
96 if (!strcasecmp(keyword, "remote")) {
97 extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
98 extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
100 if (strlen(recipients) + strlen(thisrecp) + strlen(thisdsn) + 100
101 < sizeof recipients) {
102 if (strlen(recipients) > 0) {
103 strcat(recipients, "<br />");
105 stresc(&recipients[strlen(recipients)], thisrecp, 1, 1);
106 strcat(recipients, "<br /> <i>");
107 stresc(&recipients[strlen(recipients)], thisdsn, 1, 1);
108 strcat(recipients, "</i>");
118 wprintf("%ld<br />", msgnum);
119 wprintf(" <a href=\"javascript:DeleteQueueMsg(%ld,%ld);\">%s</a>",
120 msgnum, msgid, _("(Delete)")
123 wprintf("</td><td>");
125 fmt_date(buf, submitted, 1);
132 wprintf("</td><td>");
133 if (last_attempt > 0) {
134 fmt_date(buf, last_attempt, 1);
141 wprintf("</td><td>");
144 wprintf("</td><td>");
145 wprintf("%s", recipients);
146 wprintf("</td></tr>\n");
151 void display_smtpqueue_inner_div(void) {
155 /* Check to see if we can go to the __CitadelSMTPspoolout__ room.
156 * If not, we don't have access to the queue.
158 gotoroom("__CitadelSMTPspoolout__");
159 if (!strcasecmp(WC->wc_roomname, "__CitadelSMTPspoolout__")) {
161 num_msgs = load_msg_ptrs("MSGS ALL", 0);
163 wprintf("<table class=\"mailbox_summary\" rules=rows "
164 "cellpadding=2 style=\"width:100%%;-moz-user-select:none;\">"
167 wprintf("<tr><td><b><i>");
168 wprintf(_("Message ID"));
169 wprintf("</i></b></td><td><b><i>");
170 wprintf(_("Date/time submitted"));
171 wprintf("</i></b></td><td><b><i>");
172 wprintf(_("Last attempt"));
173 wprintf("</i></b></td><td><b><i>");
174 wprintf(_("Sender"));
175 wprintf("</i></b></td><td><b><i>");
176 wprintf(_("Recipients"));
177 wprintf("</i></b></td></tr>\n");
179 for (i=0; i<num_msgs; ++i) {
180 display_queue_msg(WC->msgarr[i]);
187 wprintf("<br /><br /><div align=\"center\">");
188 wprintf(_("The queue is empty."));
189 wprintf("</div><br /><br />");
193 wprintf("<br /><br /><div align=\"center\">");
194 wprintf(_("You do not have permission to view this resource."));
195 wprintf("</div><br /><br />");
201 * \brief display the outbound SMTP queue
203 void display_smtpqueue(void)
205 output_headers(1, 1, 2, 0, 0, 0);
207 wprintf("<script type=\"text/javascript\"> \n"
208 "function RefreshQueueDisplay() { \n"
209 " new Ajax.Updater('smtpqueue_inner_div', \n"
210 " 'display_smtpqueue_inner_div', { method: 'get', \n"
211 " parameters: Math.random() } ); \n"
214 "function DeleteQueueMsg(msgnum1, msgnum2) { \n"
215 " new Ajax.Request( \n"
216 " 'ajax_servcmd', { \n"
217 " method: 'post', \n"
218 " parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2, \n"
219 " onComplete: RefreshQueueDisplay() \n"
227 wprintf("<div id=\"banner\">\n");
228 wprintf("<TABLE class=\"smtpqueue_banner\"><TR><TD>");
229 wprintf("<SPAN CLASS=\"titlebar\">");
230 wprintf(_("View the outbound SMTP queue"));
231 wprintf("</SPAN>\n");
232 wprintf("</TD></TR></TABLE>\n");
233 wprintf("</div>\n<div id=\"content\">\n");
235 wprintf("<div class=\"fix_scrollbar_bug\">"
236 "<table class=\"smtpqueue_background\">"
237 "<tr><td valign=top>\n");
239 wprintf("<div id=\"smtpqueue_inner_div\">");
241 display_smtpqueue_inner_div();
244 "<div align=\"center\">"
245 "<a href=\"javascript:RefreshQueueDisplay();\">%s</a>"
247 "</td></tr></table></div>\n", _("Refresh this page")