X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fsmtp_util.c;h=550c2e6afc9fdc8278b177574a3c6a71c1118bb1;hb=964604f73db61b2c82421eef207e05d0e9db0f82;hp=adb6fa86d48a12bbce2eb66bf2aa3ac4b80c9f66;hpb=66f72c07b70ed9500c49e8ff3c3f895e5269d339;p=citadel.git diff --git a/citadel/modules/smtp/smtp_util.c b/citadel/modules/smtp/smtp_util.c index adb6fa86d..550c2e6af 100644 --- a/citadel/modules/smtp/smtp_util.c +++ b/citadel/modules/smtp/smtp_util.c @@ -20,21 +20,15 @@ * The VRFY and EXPN commands have been removed from this implementation * because nobody uses these commands anymore, except for spammers. * - * Copyright (c) 1998-2009 by the citadel.org team + * Copyright (c) 1998-2017 by the citadel.org team * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. + * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * 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" @@ -87,6 +81,8 @@ #include "ctdl_module.h" #include "smtp_util.h" +#include "smtpqueue.h" +#include "smtp_clienthandlers.h" const char *smtp_get_Recipients(void) { @@ -94,7 +90,7 @@ const char *smtp_get_Recipients(void) if (sSMTP == NULL) return NULL; - else return sSMTP->from; + else return ChrPtr(sSMTP->from); } @@ -119,21 +115,17 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) time_t submitted = 0L; struct CtdlMessage *bmsg = NULL; int give_up = 0; - struct recptypes *valid; + recptypes *valid; int successful_bounce = 0; static int seq = 0; StrBuf *BounceMB; long omsgid = (-1); - syslog(LOG_DEBUG, "smtp_do_bounce() called\n"); + syslog(LOG_DEBUG, "smtp_do_bounce() called"); strcpy(bounceto, ""); boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_")); - StrBufAppendPrintf(boundary, - "%s_%04x%04x", - config.c_fqdn, - getpid(), - ++seq); + StrBufAppendPrintf(boundary, "%s_%04x%04x", CtdlGetConfigStr("c_fqdn"), getpid(), ++seq); lines = num_tokens(instr, '\n'); @@ -161,13 +153,11 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) bmsg->cm_magic = CTDLMESSAGE_MAGIC; bmsg->cm_anon_type = MES_NORMAL; bmsg->cm_format_type = FMT_RFC822; - bmsg->cm_fields['A'] = strdup("Citadel"); - bmsg->cm_fields['O'] = strdup(MAILROOM); - bmsg->cm_fields['N'] = strdup(config.c_nodename); - bmsg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)"); - StrBufAppendBufPlain( - BounceMB, - HKEY("Content-type: multipart/mixed; boundary=\""), 0); + CM_SetField(bmsg, eAuthor, HKEY("Citadel")); + CM_SetField(bmsg, eOriginalRoom, HKEY(MAILROOM)); + CM_SetField(bmsg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename"))); + CM_SetField(bmsg, eMsgSubject, HKEY("Delivery Status Notification (Failure)")); + StrBufAppendBufPlain(BounceMB, HKEY("Content-type: multipart/mixed; boundary=\""), 0); StrBufAppendBuf(BounceMB, boundary, 0); StrBufAppendBufPlain(BounceMB, HKEY("\"\r\n"), 0); StrBufAppendBufPlain(BounceMB, HKEY("MIME-Version: 1.0\r\n"), 0); @@ -216,8 +206,7 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) dsnlen = extract_token(dsn, buf, 3, '|', sizeof dsn); bounce_this = 0; - syslog(LOG_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>\n", - key, addr, status, dsn); + syslog(LOG_DEBUG, "key=<%s> addr=<%s> status=%d dsn=<%s>", key, addr, status, dsn); if (!strcasecmp(key, "bounceto")) { strcpy(bounceto, addr); @@ -271,7 +260,8 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) CtdlOutputMsg(omsgid, MT_RFC822, HEADERS_ALL, - 0, 1, NULL, 0); + 0, 1, NULL, 0, + NULL, NULL, NULL); StrBufAppendBuf(BounceMB, CC->redirect_buffer, 0); FreeStrBuf(&CC->redirect_buffer); @@ -285,18 +275,19 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) StrBufAppendBufPlain(BounceMB, HKEY("--"), 0); StrBufAppendBuf(BounceMB, boundary, 0); StrBufAppendBufPlain(BounceMB, HKEY("--\r\n"), 0); - if (bmsg->cm_fields['A'] != NULL) - free(bmsg->cm_fields['A']); - bmsg->cm_fields['A'] = SmashStrBuf(&BounceMB); + CM_SetAsFieldSB(bmsg, eMesageText, &BounceMB); + /* Deliver the bounce if there's anything worth mentioning */ - syslog(LOG_DEBUG, "num_bounces = %d\n", num_bounces); + syslog(LOG_DEBUG, "num_bounces = %d", num_bounces); if (num_bounces > 0) { /* First try the user who sent the message */ - if (IsEmptyStr(bounceto)) - syslog(LOG_ERR, "No bounce address specified\n"); - else - syslog(LOG_DEBUG, "bounce to user <%s>\n", bounceto); + if (IsEmptyStr(bounceto)) { + syslog(LOG_ERR, "No bounce address specified"); + } + else { + syslog(LOG_DEBUG, "bounce to user <%s>", bounceto); + } /* Can we deliver the bounce to the original sender? */ valid = validate_recipients(bounceto, smtp_get_Recipients (), @@ -310,7 +301,7 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) /* 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 */ @@ -319,6 +310,6 @@ void smtp_do_bounce(char *instr, StrBuf *OMsgTxt) } } FreeStrBuf(&boundary); - CtdlFreeMessage(bmsg); - syslog(LOG_DEBUG, "Done processing bounces\n"); + CM_Free(bmsg); + syslog(LOG_DEBUG, "Done processing bounces"); }