int num_processed = 0;
long thismsg;
struct MetaData smi;
- struct CtdlMessage *msg;
+ struct CtdlMessage *msg = NULL;
int is_seen = 0;
long lastold = 0L;
int printed_lastold = 0;
template = (struct CtdlMessage *)
malloc(sizeof(struct CtdlMessage));
memset(template, 0, sizeof(struct CtdlMessage));
+ template->cm_magic = CTDLMESSAGE_MAGIC;
+ template->cm_anon_type = MES_NORMAL;
+
while(client_getln(buf, sizeof buf), strcmp(buf,"000")) {
extract_token(tfield, buf, 0, '|', sizeof tfield);
extract_token(tvalue, buf, 1, '|', sizeof tvalue);
{
int i;
- if (is_valid_message(msg) == 0) return;
+ if (is_valid_message(msg) == 0)
+ {
+ if (msg != NULL) free (msg);
+ return;
+ }
for (i = 0; i < 256; ++i)
if (msg->cm_fields[i] != NULL) {
void cmd_msg3(char *cmdbuf)
{
long msgnum;
- struct CtdlMessage *msg;
+ struct CtdlMessage *msg = NULL;
struct ser_ret smr;
if (CC->internal_pgm == 0) {
lprintf(CTDL_DEBUG, "Delivering private local mail to <%s>\n",
recipient);
if (getuser(&userbuf, recipient) == 0) {
+ // Add a flag so the Funambol module knows its mail
+ msg->cm_fields['W'] = strdup(recipient);
MailboxName(actual_rm, sizeof actual_rm,
&userbuf, MAILROOM);
CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0, msg);
BumpNewMailCounter(userbuf.usernum);
+ if (strlen(config.c_funambol_host) > 0) {
+ /* Generate a instruction message for the Funambol notification
+ server, in the same style as the SMTP queue */
+ instr = malloc(SIZ * 2);
+ snprintf(instr, SIZ * 2,
+ "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
+ "bounceto|%s@%s\n",
+ SPOOLMIME, newmsgid, (long)time(NULL),
+ msg->cm_fields['A'], msg->cm_fields['N']
+ );
+
+ imsg = malloc(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['A'] = strdup("Citadel");
+ imsg->cm_fields['J'] = strdup("do not journal");
+ imsg->cm_fields['M'] = instr;
+ imsg->cm_fields['W'] = strdup(recipient);
+ CtdlSubmitMsg(imsg, NULL, FNBL_QUEUE_ROOM);
+ CtdlFreeMessage(imsg);
+ }
}
else {
lprintf(CTDL_DEBUG, "No user <%s>\n", recipient);