You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mod_smtp_mailing_lists: Further fix list reply behavior.
* Ignore existing Reply-To headers in submitted messages.
* Ensure the list is always in the To or Cc headers,
so that reply all will go to the list if replyto=sender.
* Actually load the 'name' setting when parsing config.
* Add tests for list name and reply behavior.
fprintf(fp, "From: %s\r\n", from); /* Use the original From header */
402
408
}
403
409
}
410
+
} elseif (STARTS_WITH(buf, "Reply-To:")) {
411
+
/* We add our own Reply-To header, so if the message came in with one, ignore it */
412
+
continue;
413
+
} elseif (STARTS_WITH(buf, "To:")) {
414
+
/*
415
+
* The Reply-To header is easy, as that simply follows the replyto setting.
416
+
*
417
+
* The To and Cc headers are a bit tricky for us.
418
+
* We need to largely preserve what is already in these headers, but:
419
+
* - If the list is not present in either of them, add it (so that reply all works)
420
+
*
421
+
* We'll try adding the list to 'To' by default, but if it's in the Cc for some reason, we'll leave that alone, doesn't matter for reply all.
422
+
* If the list is in both the To and Cc headers, that should be okay, proper mail clients should discard the Cc and just keep the To (at least Mozilla does)
423
+
*
424
+
* For example, if a user sends an email with the list in Bcc, so it's not originally in either header, we'll add it to the To header.
425
+
*
426
+
* Note that addresses can appear in both To/Cc and Reply-To. If this happens, Mozilla picks the name from the To/Cc headers (but follows Reply-To for reply).
427
+
*
428
+
* Testing Note: If you send a message to the list in Mozilla and the Reply-To is your address in the current mailbox, with replyto=sender, "Reply" will yield no recipients,
429
+
* while Reply To only includes the list - it's smart enough to prevent you from just emailing yourself when you click Reply.
430
+
*/
431
+
got_to=1;
432
+
if (strstr(buf, baselistaddr)) {
433
+
list_in_to=1;
434
+
fprintf(fp, "%s\r\n", buf);
435
+
} else {
436
+
/* We've gotten both headers and the list isn't in either. Add it to 'To' now. */
437
+
if (got_cc&& !list_in_cc) {
438
+
char*hdrval=buf+STRLEN("To:");
439
+
ltrim(hdrval);
440
+
fprintf(fp, "To: %s,%s\r\n", hdrval, listaddr); /* no space between comma-separated recipients */
441
+
} else {
442
+
fprintf(fp, "%s\r\n", buf);
443
+
}
444
+
}
445
+
} elseif (STARTS_WITH(buf, "Cc:")) {
446
+
got_cc=1;
447
+
if (strstr(buf, baselistaddr)) {
448
+
list_in_cc=1;
449
+
fprintf(fp, "%s\r\n", buf);
450
+
} else {
451
+
/* We've gotten both headers and the list isn't in either. Add it to 'Cc' now, since it's too late to add it to 'To' */
452
+
if (got_to&& !list_in_to) {
453
+
char*hdrval=buf+STRLEN("Cc:");
454
+
ltrim(hdrval);
455
+
fprintf(fp, "Cc: %s,%s\r\n", hdrval, listaddr); /* no space between comma-separated recipients */
456
+
} else {
457
+
fprintf(fp, "%s\r\n", buf);
458
+
}
459
+
}
404
460
} else {
405
461
fprintf(fp, "%s\r\n", buf); /* Just copy it over */
406
462
}
407
463
}
464
+
if (!list_in_to&& !list_in_cc) {
465
+
/* If this happens, then we only got one of the To and Cc headers or we would have put it in the second one encountered.
466
+
* So, add the missing header, containing the list. */
/* Past this point, all messages are from an external sender, only the dmarcmungetest list: */
229
236
230
237
/* Test an external email address, which should munge the From address
231
238
* If TEST_WITH_REAL_DMARC_POLICIES isn't defined, mod_smtp_filter_dmarc isn't loaded, so it should fail safe with BBS_DMARC_POLICY_ERROR and munge anyways
0 commit comments