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")) {
103 extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
104 extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
105 RcptLen = strlen(recipients);
106 TRcptLen = strlen(thisrecp);
107 TDsn = strlen(thisdsn);
108 if ( RcptLen + TRcptLen + TDsn + 100
109 < sizeof recipients) {
110 if (!IsEmptyStr(recipients)) {
111 // copy the \0 to be sure..
112 memcpy (&recipients[RcptLen], "<br />\0", 7);
115 NLen = stresc(&recipients[RcptLen],
116 sizeof recipients - RcptLen,
121 NLen = sizeof "<br /> <i>";
122 memcpy(recipients, "<br /> <i>",
125 NLen = stresc(&recipients[RcptLen],
126 sizeof recipients - RcptLen,
129 memcpy (recipients, "</i>\0", 5);
140 wprintf("%ld<br />", msgnum);
141 wprintf(" <a href=\"javascript:DeleteQueueMsg(%ld,%ld);\">%s</a>",
142 msgnum, msgid, _("(Delete)")
145 wprintf("</td><td>");
147 webcit_fmt_date(buf, submitted, 1);
154 wprintf("</td><td>");
155 if (last_attempt > 0) {
156 webcit_fmt_date(buf, last_attempt, 1);
163 wprintf("</td><td>");
166 wprintf("</td><td>");
167 wprintf("%s", recipients);
168 wprintf("</td></tr>\n");
173 void display_smtpqueue_inner_div(void) {
177 /* Check to see if we can go to the __CitadelSMTPspoolout__ room.
178 * If not, we don't have access to the queue.
180 gotoroom("__CitadelSMTPspoolout__");
181 if (!strcasecmp(WC->wc_roomname, "__CitadelSMTPspoolout__")) {
183 num_msgs = load_msg_ptrs("MSGS ALL", 0);
185 wprintf("<table class=\"mailbox_summary\" rules=rows "
186 "cellpadding=2 style=\"width:100%%;-moz-user-select:none;\">"
189 wprintf("<tr><td><b><i>");
190 wprintf(_("Message ID"));
191 wprintf("</i></b></td><td><b><i>");
192 wprintf(_("Date/time submitted"));
193 wprintf("</i></b></td><td><b><i>");
194 wprintf(_("Last attempt"));
195 wprintf("</i></b></td><td><b><i>");
196 wprintf(_("Sender"));
197 wprintf("</i></b></td><td><b><i>");
198 wprintf(_("Recipients"));
199 wprintf("</i></b></td></tr>\n");
201 for (i=0; i<num_msgs; ++i) {
202 display_queue_msg(WC->msgarr[i]);
209 wprintf("<br /><br /><div align=\"center\">");
210 wprintf(_("The queue is empty."));
211 wprintf("</div><br /><br />");
215 wprintf("<br /><br /><div align=\"center\">");
216 wprintf(_("You do not have permission to view this resource."));
217 wprintf("</div><br /><br />");
223 * \brief display the outbound SMTP queue
225 void display_smtpqueue(void)
227 output_headers(1, 1, 2, 0, 0, 0);
229 wprintf("<script type=\"text/javascript\"> \n"
230 "function RefreshQueueDisplay() { \n"
231 " new Ajax.Updater('smtpqueue_inner_div', \n"
232 " 'display_smtpqueue_inner_div', { method: 'get', \n"
233 " parameters: Math.random() } ); \n"
236 "function DeleteQueueMsg(msgnum1, msgnum2) { \n"
237 " new Ajax.Request( \n"
238 " 'ajax_servcmd', { \n"
239 " method: 'post', \n"
240 " parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2, \n"
241 " onComplete: RefreshQueueDisplay() \n"
249 wprintf("<div id=\"banner\">\n");
251 wprintf(_("View the outbound SMTP queue"));
255 wprintf("<div id=\"content\" class=\"service\">\n");
257 wprintf("<div class=\"fix_scrollbar_bug\">"
258 "<table class=\"smtpqueue_background\">"
259 "<tr><td valign=top>\n");
261 wprintf("<div id=\"smtpqueue_inner_div\">");
263 display_smtpqueue_inner_div();
266 "<div align=\"center\">"
267 "<a href=\"javascript:RefreshQueueDisplay();\">%s</a>"
269 "</td></tr></table></div>\n", _("Refresh this page")