* The VRFY and EXPN commands have been removed from this implementation
* because nobody uses these commands anymore, except for spammers.
*
- * Copyright (c) 1998-2012 by the citadel.org team
+ * Copyright (c) 1998-2015 by the citadel.org team
*
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3.
- *
- *
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
*
- *
- *
- *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*/
#include "sysdep.h"
0, 1, NULL,
(ESC_DOT|SUPPRESS_ENV_TO),
Author,
- Address);
+ Address,
+ NULL);
SendMsg = CCC->redirect_buffer;
CCC->redirect_buffer = NULL;
StrBuf *boundary;
StrBuf *Msg = NULL;
StrBuf *BounceMB;
- struct recptypes *valid;
+ recptypes *valid;
time_t now;
HashPos *It;
boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
StrBufAppendPrintf(boundary,
"%s_%04x%04x",
- config.c_fqdn,
+ CtdlGetConfigStr("c_fqdn"),
getpid(),
++seq);
CM_SetField(bmsg, eOriginalRoom, HKEY(MAILROOM));
CM_SetField(bmsg, eAuthor, HKEY("Citadel"));
- CM_SetField(bmsg, eNodeName, config.c_nodename, strlen(config.c_nodename));
+ CM_SetField(bmsg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
CM_SetField(bmsg, eMsgSubject, HKEY("Delivery Status Notification (Failure)"));
CM_SetAsFieldSB(bmsg, eMesageText, &BounceMB);
/* If not, post it in the Aide> room */
if (successful_bounce == 0) {
- CtdlSubmitMsg(bmsg, NULL, config.c_aideroom, QP_EADDR);
+ CtdlSubmitMsg(bmsg, NULL, CtdlGetConfigStr("c_aideroom"), QP_EADDR);
}
/* Free up the memory we used */
/* Strip out the headers (no not amd any other non-instruction) line */
while (pch != NULL) {
pch = strchr(pch, '\n');
- if ((pch != NULL) && (*(pch + 1) == '\n')) {
+ if ((pch != NULL) &&
+ ((*(pch + 1) == '\n') ||
+ (*(pch + 1) == '\r')))
+ {
instr = pch + 2;
pch = NULL;
}
}
+int smtp_aftersave(struct CtdlMessage *msg,
+ recptypes *recps)
+{
+ /* For internet mail, generate delivery instructions.
+ * Yes, this is recursive. Deal with it. Infinite recursion does
+ * not happen because the delivery instructions message does not
+ * contain a recipient.
+ */
+ if ((recps != NULL) && (recps->num_internet > 0)) {
+ struct CtdlMessage *imsg = NULL;
+ char recipient[SIZ];
+ CitContext *CCC = MyContext();
+ StrBuf *SpoolMsg = NewStrBuf();
+ long nTokens;
+ int i;
+
+ MSGM_syslog(LOG_DEBUG, "Generating delivery instructions\n");
+
+ StrBufPrintf(SpoolMsg,
+ "Content-type: "SPOOLMIME"\n"
+ "\n"
+ "msgid|%s\n"
+ "submitted|%ld\n"
+ "bounceto|%s\n",
+ msg->cm_fields[eVltMsgNum],
+ (long)time(NULL),
+ recps->bounce_to);
+
+ if (recps->envelope_from != NULL) {
+ StrBufAppendBufPlain(SpoolMsg, HKEY("envelope_from|"), 0);
+ StrBufAppendBufPlain(SpoolMsg, recps->envelope_from, -1, 0);
+ StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
+ }
+ if (recps->sending_room != NULL) {
+ StrBufAppendBufPlain(SpoolMsg, HKEY("source_room|"), 0);
+ StrBufAppendBufPlain(SpoolMsg, recps->sending_room, -1, 0);
+ StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
+ }
+
+ nTokens = num_tokens(recps->recp_internet, '|');
+ for (i = 0; i < nTokens; i++) {
+ long len;
+ len = extract_token(recipient, recps->recp_internet, i, '|', sizeof recipient);
+ if (len > 0) {
+ StrBufAppendBufPlain(SpoolMsg, HKEY("remote|"), 0);
+ StrBufAppendBufPlain(SpoolMsg, recipient, len, 0);
+ StrBufAppendBufPlain(SpoolMsg, HKEY("|0||\n"), 0);
+ }
+ }
+
+ 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;
+ CM_SetField(imsg, eMsgSubject, HKEY("QMSG"));
+ CM_SetField(imsg, eAuthor, HKEY("Citadel"));
+ CM_SetField(imsg, eJournal, HKEY("do not journal"));
+ CM_SetAsFieldSB(imsg, eMesageText, &SpoolMsg);
+ CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
+ CM_Free(imsg);
+ }
+ return 0;
+}
CTDL_MODULE_INIT(smtp_queu)
{
if ((pstr != NULL) && (*pstr != '\0'))
delay_msec = atol(pstr) * 1000; /* this many seconds. */
-
-
+ CtdlRegisterMessageHook(smtp_aftersave, EVT_AFTERSAVE);
CtdlFillSystemContext(&smtp_queue_CC, "SMTP_Send");
ActiveQItems = NewHash(1, lFlathash);