X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fserv_smtp.c;h=4c694c342b534ed86c117365256898483682ebdc;hb=5dc36f6bbd05e378117d8a47fb759916d689376f;hp=517e5d040f6c611b8ea5642ee3fcb3ad62b0b5e1;hpb=191fc259cbd372321bef819072a91457410ca323;p=citadel.git diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 517e5d040..4c694c342 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -669,6 +669,20 @@ void smtp_command_loop(void) { +/* + * smtp_try() + * + * Called by smtp_do_procmsg() to attempt delivery to one SMTP host + * + */ +void smtp_try(char *key, char *addr, int *status, char *dsn) { + + *status = 3; + strcpy(dsn, "smtp_try() is not finished yet"); +} + + + /* * smtp_do_procmsg() * @@ -676,12 +690,16 @@ void smtp_command_loop(void) { */ void smtp_do_procmsg(long msgnum) { struct CtdlMessage *msg; - char *instr; + char *instr = NULL; + char *results = NULL; int i; int lines; - char buf[256]; - char key[256]; - long msgid = (-1); + int status; + char buf[1024]; + char key[1024]; + char addr[1024]; + char dsn[1024]; + long text_msgid = (-1); msg = CtdlFetchMessage(msgnum); if (msg == NULL) { @@ -689,12 +707,13 @@ void smtp_do_procmsg(long msgnum) { return; } - instr = msg->cm_fields['M']; + instr = strdoop(msg->cm_fields['M']); + CtdlFreeMessage(msg); /* Strip out the headers amd any other non-instruction line */ lines = num_tokens(instr, '\n'); for (i=0; i\n", buf); remove_token(instr, i, '|'); @@ -706,19 +725,68 @@ void smtp_do_procmsg(long msgnum) { /* Learn the message ID */ lines = num_tokens(instr, '\n'); for (i=0; i\n", addr); + smtp_try(key, addr, &status, dsn); + if (status != 2) { + if (results == NULL) { + results = mallok(1024); + memset(results, 0, 1024); + } + else { + results = reallok(results, + strlen(results) + 1024); + } + sprintf(&results[strlen(results)], + "%s|%s|%d|%s\n", + key, addr, status, dsn); + } + } + } + if (results != NULL) { + instr = reallok(instr, strlen(instr) + strlen(results) + 2); + strcat(instr, results); + phree(results); + } + /* Delete the instructions and replace with the updated ones */ + CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, msgnum, NULL); + msg = mallok(sizeof(struct CtdlMessage)); + memset(msg, 0, sizeof(struct CtdlMessage)); + msg->cm_magic = CTDLMESSAGE_MAGIC; + msg->cm_anon_type = MES_NORMAL; + msg->cm_format_type = FMT_RFC822; + msg->cm_fields['M'] = instr; + CtdlSaveMsg(msg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL, 1); CtdlFreeMessage(msg); }