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: <%s>\r\n", unsubscribe_url); // RFC 2369
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);
char *dkim_private_key = CtdlGetConfigStr("dkim_private_key");
char *dkim_selector = CtdlGetConfigStr("dkim_selector");
char *dkim_from_domain = (strchr(fromaddr, '@') ? strchr(fromaddr, '@')+1 : NULL);
- if (!IsEmptyStr(dkim_private_key) && !IsEmptyStr(dkim_selector) && !IsEmptyStr(dkim_from_domain)) {
- char *pkey = strdup(dkim_private_key);
- if (pkey) {
- char *sp;
- while (sp = strchr(pkey, '_')) {
- *sp = '\n';
- }
- syslog(LOG_DEBUG, "private key: <%s>\n", pkey);
- dkim_sign(s.TheMessage, pkey, dkim_from_domain, dkim_selector);
- free(pkey);
- }
+ if (
+ !IsEmptyStr(dkim_from_domain) // Is the sending domain non-empty?
+ && IsDirectory(fromaddr, 0) // and is it one of "our" domains?
+ && !IsEmptyStr(dkim_private_key) // Do we have a private signing key?
+ && !IsEmptyStr(dkim_selector) // and a selector to go with it?
+ ) {
+ // If you answered "yes" to all of the above questions, congratulations! We get to sign the message!
+ syslog(LOG_DEBUG, "smtpclient: dkim-signing for selector <%s> in domain <%s>", dkim_selector, dkim_from_domain);
+
+ // Remember, the dkim_sign() function is capable of handling a PEM-encoded PKCS#7 private key that
+ // has had all of its newlines replaced by underscores -- which is exactly how we store it.
+ dkim_sign(s.TheMessage,dkim_private_key, dkim_from_domain, dkim_selector);
}
// Prepare the buffer for transmittal
CtdlRegisterSessionHook(smtp_do_queue_quick, EVT_HOUSE, PRIO_AGGR + 51);
CtdlRegisterSessionHook(smtp_do_queue_full, EVT_TIMER, PRIO_AGGR + 51);
smtp_init_spoolout();
+ dkim_init();
}
// return our module id for the log