]> code.citadel.org Git - citadel.git/commitdiff
* Completed spool to outbound delivery queue (still no queue sender implemented)
authorArt Cancro <ajc@citadel.org>
Sat, 8 Jan 2000 22:19:44 +0000 (22:19 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 8 Jan 2000 22:19:44 +0000 (22:19 +0000)
citadel/ChangeLog
citadel/citadel.h
citadel/msgbase.c
citadel/serv_smtp.c

index 5c2688f39e4c66af4c98f0ad98dd547eda5593aa..057fb140c5d8e7c2e5ec19c0ff98563e7d5ce7ed 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 1.437  2000/01/08 22:19:44  ajc
+* Completed spool to outbound delivery queue (still no queue sender implemented)
+
 Revision 1.436  2000/01/08 05:00:09  ajc
 * Reworked some of the data structures to handle multiple recipients
 * Began implementation of the delivery queue
@@ -1524,3 +1527,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index 210f9a28194b52abca73fb5664533211738fe1e2..7c8530945597fc97eba14886add5e617bf4e9635 100644 (file)
@@ -244,6 +244,7 @@ struct floor {
 #define AIDEROOM       "Aide"
 #define CONFIGROOM     "My Citadel Config"
 
+#define SPOOLMIME      "application/x-citadel-delivery-list"
 
 /*
  * This structure is used to hold all of the fields of a message
index 6615cffc0107183e26f0d7a80f53b98d9de16f8d..48515e8719e7b310837bb71f8aa326cc166f9051 100644 (file)
@@ -1406,7 +1406,7 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */
        char content_type[256];                 /* We have to learn this */
        char recipient[256];
        long newmsgid;
-       char *mptr;
+       char *mptr = NULL;
        struct usersupp userbuf;
        int a;
        struct SuppMsgInfo smi;
@@ -1452,6 +1452,9 @@ long CtdlSaveMsg(struct CtdlMessage *msg, /* message to save */
 
        /* Learn about what's inside, because it's what's inside that counts */
        lprintf(9, "Learning what's inside\n");
+       if (msg->cm_fields['M'] == NULL) {
+               lprintf(1, "ERROR: attempt to save message with NULL body\n");
+       }
 
        switch (msg->cm_format_type) {
        case 0:
index 34a96804776b1b7ca620112d186ef62fc6d9f05b..0345dd2395648d9315e0172bef27164980e6e382 100644 (file)
@@ -41,7 +41,6 @@ struct citsmtp {              /* Information about the current session */
        int delivery_mode;
 };
 
-
 enum {                         /* Command states for login authentication */
        smtp_command,
        smtp_user,
@@ -403,12 +402,20 @@ void smtp_rcpt(char *argbuf) {
  * Returns 0 on success, nonzero on failure
  */
 int smtp_message_delivery(struct CtdlMessage *msg) {
-       char user[256];
-       char node[256];
-       char name[256];
-       int successful_saves = 0;
-       int failed_saves = 0;
+       char user[1024];
+       char node[1024];
+       char name[1024];
+       char buf[1024];
+       char dtype[1024];
+       char room[1024];
+       int successful_saves = 0;       /* number of successful local saves */
+       int failed_saves = 0;           /* number of failed deliveries */
+       int remote_spools = 0;          /* number of copies to send out */
        long msgid = (-1L);
+       int i;
+       struct usersupp userbuf;
+       char *instr;                    /* Remote delivery instructions */
+       struct CtdlMessage *imsg;
 
        lprintf(9, "smtp_message_delivery() called\n");
 
@@ -426,10 +433,57 @@ int smtp_message_delivery(struct CtdlMessage *msg) {
                1);
        ++successful_saves;
 
-               /* FIX go thru each local user and save to boxes
-                       then stuff remote users in queue list
-                       then delete from queue if num remote users is 0
-               */
+       instr = mallok(1024);
+       sprintf(instr, "Content-type: %s\n\nmsgid|%ld\n",
+               SPOOLMIME, msgid);
+
+       for (i=0; i<SMTP->number_of_recipients; ++i) {
+               extract_token(buf, SMTP_RECP, i, '\n');
+               extract(dtype, buf, 0);
+
+               /* Stuff local mailboxes */
+               if (!strcasecmp(dtype, "local")) {
+                       extract(user, buf, 1);
+                       if (getuser(&userbuf, user) == 0) {
+                               MailboxName(room, &userbuf, MAILROOM);
+                               CtdlSaveMsgPointerInRoom(room, msgid, 0);
+                               ++successful_saves;
+                       }
+                       else {
+                               ++failed_saves;
+                       }
+               }
+
+               /* Remote delivery */
+               if (!strcasecmp(dtype, "remote")) {
+                       extract(user, buf, 1);
+                       instr = reallok(instr, strlen(instr) + 1024);
+                       sprintf(&instr[strlen(instr)],
+                               "remote|%s|0\n",
+                               user);
+                       ++remote_spools;
+               }
+
+       }
+
+       /* If there are remote spools to be done, save the instructions */
+       if (remote_spools > 0) {
+               imsg = mallok(sizeof(struct CtdlMessage));
+               memset(imsg, 0, sizeof(struct CtdlMessage));
+               imsg->cm_magic = CTDLMESSAGE_MAGIC;
+               imsg->cm_anon_type = MES_NORMAL;
+               imsg->cm_format_type = FMT_RFC822;
+               imsg->cm_fields['M'] = instr;
+               CtdlSaveMsg(imsg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL, 1);
+               CtdlFreeMessage(imsg);
+       }
+
+       /* If there are no remote spools, delete the message */ 
+       else {
+               phree(instr);   /* only needed here, because CtdlSaveMsg()
+                                * would free this buffer otherwise */
+               CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, msgid, NULL); 
+       }
 
        return(failed_saves);
 }
@@ -495,7 +549,7 @@ void smtp_data(void) {
                cprintf("250 Message accepted for delivery.\n");
        }
        else {
-               cprintf("550 Internal error.\n");
+               cprintf("550 Internal delivery errors: %d\n", retval);
        }
 }
 
@@ -577,7 +631,7 @@ void smtp_command_loop(void) {
        }
 
        else {
-               cprintf("502 I'm afraid I can't do that, Dave.\n");
+               cprintf("502 I'm sorry Dave, I'm afraid I can't do that.\n");
        }
 
 }