X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fserver%2Fmodules%2Fsmtp%2Fserv_smtpclient.c;h=e169f9e7cdd507ce42a4b77becf0ef4c2bdfbda5;hb=99efe55958ebc96ab99b052dc67864ea1db64a62;hp=edce1f5c387088008f16b42ca651860bb6d42dbb;hpb=605133afb3d87139c657794d647c3a49df8b6a47;p=citadel.git diff --git a/citadel/server/modules/smtp/serv_smtpclient.c b/citadel/server/modules/smtp/serv_smtpclient.c index edce1f5c3..e169f9e7c 100644 --- a/citadel/server/modules/smtp/serv_smtpclient.c +++ b/citadel/server/modules/smtp/serv_smtpclient.c @@ -2,7 +2,7 @@ // // This is the new, exciting, clever version that makes libcurl do all the work :) // -// Copyright (c) 1997-2023 by the citadel.org team +// Copyright (c) 1997-2024 by the citadel.org team // // This program is open source software. Use, duplication, or disclosure // is subject to the terms of the GNU General Public License, version 3. @@ -213,29 +213,32 @@ int smtp_attempt_delivery(long msgid, char *recp, char *envelope_from, char *sou process_rfc822_addr(recp, user, node, name); // split recipient address into username, hostname, displayname num_mx = getmx(mxes, node); if (num_mx < 1) { - return (421); + return(421); } CC->redirect_buffer = NewStrBufPlain(NULL, SIZ); + + // If we have a source room, it's probably a mailing list message; generate an unsubscribe header if (!IsEmptyStr(source_room)) { - // If we have a source room, it's probably a mailing list message; generate an unsubscribe header - char esc_room[ROOMNAMELEN*2]; - char esc_email[1024]; - urlesc(esc_room, sizeof esc_room, source_room); - urlesc(esc_email, sizeof esc_email, recp); - cprintf("List-Unsubscribe: \r\n", - CtdlGetConfigStr("c_fqdn"), - esc_room, - esc_email - ); + char base_url[SIZ]; + char unsubscribe_url[SIZ]; + snprintf(base_url, sizeof base_url, "https://%s/listsub", CtdlGetConfigStr("c_fqdn")); + generate_one_click_url(unsubscribe_url, base_url, "unsubscribe", source_room, recp); + cprintf("List-Unsubscribe: %s\r\n", unsubscribe_url); + cprintf("List-Unsubscribe-Post: List-Unsubscribe=One-Click\r\n"); // RFC 8058 + } + CtdlOutputMsg(msgid, MT_RFC822, HEADERS_ALL, 0, 1, NULL, 0, NULL, &fromaddr, NULL); s.TheMessage = CC->redirect_buffer; - s.bytes_total = StrLength(CC->redirect_buffer); - s.bytes_sent = 0; CC->redirect_buffer = NULL; + s.bytes_total = StrLength(s.TheMessage); + s.bytes_sent = 0; response_code = 421; - // keep trying MXes until one works or we run out + + // Future enhancement: if we implement DKIM signing, this is where it must happen. + + // Keep trying MXes until one works or we run out. for (i = 0; ((i < num_mx) && ((response_code / 100) == 4)); ++i) { response_code = 421; // default 421 makes non-protocol errors transient s.bytes_sent = 0; // rewind our buffer in case we try multiple MXes @@ -323,7 +326,7 @@ void smtp_process_one_msg(long qmsgnum) { msg = CtdlFetchMessage(qmsgnum, 1); if (msg == NULL) { - syslog(LOG_WARNING, "smtpclient: %ld does not exist", qmsgnum); + syslog(LOG_WARNING, "smtpclient: msg#%ld does not exist", qmsgnum); return; } @@ -463,7 +466,7 @@ void smtp_process_one_msg(long qmsgnum) { } } else { - syslog(LOG_DEBUG, "smtpclient: %ld retry time not reached", qmsgnum); + syslog(LOG_DEBUG, "smtpclient: msg#%ld retry time not reached", qmsgnum); } if (bounceto != NULL) {