Fossil SCM

Provide the ability to add a List-Id: header on out-bound notification emails.

drh 2022-05-25 20:03 trunk
Commit e50c3629b8cd6c8f2bb24ff9ab8fe4ec5fb37f8334113165269fe99a152c4aca
1 file changed +19
+19
--- src/alerts.c
+++ src/alerts.c
@@ -278,10 +278,18 @@
278278
@ the "From:" address of the email notification.
279279
@ The system administrator should arrange for emails sent to this address
280280
@ to be handed off to the "fossil email incoming" command so that Fossil
281281
@ can handle bounces. (Property: "email-self")</p>
282282
@ <hr>
283
+
284
+ entry_attribute("List-ID", 40, "email-listid",
285
+ "elistid", "", 0);
286
+ @ <p>
287
+ @ If this is not an empty string, then it becomes the argument to
288
+ @ a "List-ID:" header on all out-bound notification emails.
289
+ @ (Property: "email-listid")</p>
290
+ @ <hr>
283291
284292
entry_attribute("Repository Nickname", 16, "email-subname",
285293
"enn", "", 0);
286294
@ <p><b>Required.</b>
287295
@ This is short name used to identifies the repository in the
@@ -409,10 +417,11 @@
409417
const char *zDest; /* How to send email. */
410418
const char *zDb; /* Name of database file */
411419
const char *zDir; /* Directory in which to store as email files */
412420
const char *zCmd; /* Command to run for each email */
413421
const char *zFrom; /* Emails come from here */
422
+ const char *zListId; /* Argument to List-ID header */
414423
SmtpSession *pSmtp; /* SMTP relay connection */
415424
Blob out; /* For zDest=="blob" */
416425
char *zErr; /* Error message */
417426
u32 mFlags; /* Flags */
418427
int bImmediateFail; /* On any error, call fossil_fatal() */
@@ -434,10 +443,11 @@
434443
sqlite3_close(p->db);
435444
p->db = 0;
436445
p->zDb = 0;
437446
p->zDir = 0;
438447
p->zCmd = 0;
448
+ p->zListId = 0;
439449
if( p->pSmtp ){
440450
smtp_client_quit(p->pSmtp);
441451
smtp_session_free(p->pSmtp);
442452
p->pSmtp = 0;
443453
}
@@ -514,10 +524,11 @@
514524
}else{
515525
p->zDest = db_get("email-send-method",0);
516526
}
517527
if( fossil_strcmp(p->zDest,"off")==0 ) return p;
518528
if( emailerGetSetting(p, &p->zFrom, "email-self") ) return p;
529
+ p->zListId = db_get("email-listid", 0);
519530
if( fossil_strcmp(p->zDest,"db")==0 ){
520531
char *zErr;
521532
int rc;
522533
if( emailerGetSetting(p, &p->zDb, "email-send-db") ) return p;
523534
rc = sqlite3_open(p->zDb, &p->db);
@@ -881,10 +892,13 @@
881892
blob_appendf(pOut, "Sender: <%s>\r\n", p->zFrom);
882893
}else{
883894
blob_appendf(pOut, "From: <%s>\r\n", p->zFrom);
884895
}
885896
blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0)));
897
+ if( p->zListId && p->zListId[0] ){
898
+ blob_appendf(pOut, "List-Id: %s\r\n", p->zListId);
899
+ }
886900
if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){
887901
/* Message-id format: "<$(date)x$(random)@$(from-host)>" where $(date) is
888902
** the current unix-time in hex, $(random) is a 64-bit random number,
889903
** and $(from) is the domain part of the email-self setting. */
890904
sqlite3_randomness(sizeof(r1), &r1);
@@ -1029,10 +1043,15 @@
10291043
/*
10301044
** SETTING: email-self width=40
10311045
** This is the email address for the repository. Outbound emails add
10321046
** this email address as the "From:" field.
10331047
*/
1048
+/*
1049
+** SETTING: email-listid width=40
1050
+** If this setting is not an empty string, then it becomes the argument to
1051
+** a "List-ID:" header that is added to all out-bound notification emails.
1052
+*/
10341053
/*
10351054
** SETTING: email-send-relayhost width=40 sensitive
10361055
** This is the hostname and TCP port to which output email messages
10371056
** are sent when email-send-method is "relay". There should be an
10381057
** SMTP server configured as a Mail Submission Agent listening on the
10391058
--- src/alerts.c
+++ src/alerts.c
@@ -278,10 +278,18 @@
278 @ the "From:" address of the email notification.
279 @ The system administrator should arrange for emails sent to this address
280 @ to be handed off to the "fossil email incoming" command so that Fossil
281 @ can handle bounces. (Property: "email-self")</p>
282 @ <hr>
 
 
 
 
 
 
 
 
283
284 entry_attribute("Repository Nickname", 16, "email-subname",
285 "enn", "", 0);
286 @ <p><b>Required.</b>
287 @ This is short name used to identifies the repository in the
@@ -409,10 +417,11 @@
409 const char *zDest; /* How to send email. */
410 const char *zDb; /* Name of database file */
411 const char *zDir; /* Directory in which to store as email files */
412 const char *zCmd; /* Command to run for each email */
413 const char *zFrom; /* Emails come from here */
 
414 SmtpSession *pSmtp; /* SMTP relay connection */
415 Blob out; /* For zDest=="blob" */
416 char *zErr; /* Error message */
417 u32 mFlags; /* Flags */
418 int bImmediateFail; /* On any error, call fossil_fatal() */
@@ -434,10 +443,11 @@
434 sqlite3_close(p->db);
435 p->db = 0;
436 p->zDb = 0;
437 p->zDir = 0;
438 p->zCmd = 0;
 
439 if( p->pSmtp ){
440 smtp_client_quit(p->pSmtp);
441 smtp_session_free(p->pSmtp);
442 p->pSmtp = 0;
443 }
@@ -514,10 +524,11 @@
514 }else{
515 p->zDest = db_get("email-send-method",0);
516 }
517 if( fossil_strcmp(p->zDest,"off")==0 ) return p;
518 if( emailerGetSetting(p, &p->zFrom, "email-self") ) return p;
 
519 if( fossil_strcmp(p->zDest,"db")==0 ){
520 char *zErr;
521 int rc;
522 if( emailerGetSetting(p, &p->zDb, "email-send-db") ) return p;
523 rc = sqlite3_open(p->zDb, &p->db);
@@ -881,10 +892,13 @@
881 blob_appendf(pOut, "Sender: <%s>\r\n", p->zFrom);
882 }else{
883 blob_appendf(pOut, "From: <%s>\r\n", p->zFrom);
884 }
885 blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0)));
 
 
 
886 if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){
887 /* Message-id format: "<$(date)x$(random)@$(from-host)>" where $(date) is
888 ** the current unix-time in hex, $(random) is a 64-bit random number,
889 ** and $(from) is the domain part of the email-self setting. */
890 sqlite3_randomness(sizeof(r1), &r1);
@@ -1029,10 +1043,15 @@
1029 /*
1030 ** SETTING: email-self width=40
1031 ** This is the email address for the repository. Outbound emails add
1032 ** this email address as the "From:" field.
1033 */
 
 
 
 
 
1034 /*
1035 ** SETTING: email-send-relayhost width=40 sensitive
1036 ** This is the hostname and TCP port to which output email messages
1037 ** are sent when email-send-method is "relay". There should be an
1038 ** SMTP server configured as a Mail Submission Agent listening on the
1039
--- src/alerts.c
+++ src/alerts.c
@@ -278,10 +278,18 @@
278 @ the "From:" address of the email notification.
279 @ The system administrator should arrange for emails sent to this address
280 @ to be handed off to the "fossil email incoming" command so that Fossil
281 @ can handle bounces. (Property: "email-self")</p>
282 @ <hr>
283
284 entry_attribute("List-ID", 40, "email-listid",
285 "elistid", "", 0);
286 @ <p>
287 @ If this is not an empty string, then it becomes the argument to
288 @ a "List-ID:" header on all out-bound notification emails.
289 @ (Property: "email-listid")</p>
290 @ <hr>
291
292 entry_attribute("Repository Nickname", 16, "email-subname",
293 "enn", "", 0);
294 @ <p><b>Required.</b>
295 @ This is short name used to identifies the repository in the
@@ -409,10 +417,11 @@
417 const char *zDest; /* How to send email. */
418 const char *zDb; /* Name of database file */
419 const char *zDir; /* Directory in which to store as email files */
420 const char *zCmd; /* Command to run for each email */
421 const char *zFrom; /* Emails come from here */
422 const char *zListId; /* Argument to List-ID header */
423 SmtpSession *pSmtp; /* SMTP relay connection */
424 Blob out; /* For zDest=="blob" */
425 char *zErr; /* Error message */
426 u32 mFlags; /* Flags */
427 int bImmediateFail; /* On any error, call fossil_fatal() */
@@ -434,10 +443,11 @@
443 sqlite3_close(p->db);
444 p->db = 0;
445 p->zDb = 0;
446 p->zDir = 0;
447 p->zCmd = 0;
448 p->zListId = 0;
449 if( p->pSmtp ){
450 smtp_client_quit(p->pSmtp);
451 smtp_session_free(p->pSmtp);
452 p->pSmtp = 0;
453 }
@@ -514,10 +524,11 @@
524 }else{
525 p->zDest = db_get("email-send-method",0);
526 }
527 if( fossil_strcmp(p->zDest,"off")==0 ) return p;
528 if( emailerGetSetting(p, &p->zFrom, "email-self") ) return p;
529 p->zListId = db_get("email-listid", 0);
530 if( fossil_strcmp(p->zDest,"db")==0 ){
531 char *zErr;
532 int rc;
533 if( emailerGetSetting(p, &p->zDb, "email-send-db") ) return p;
534 rc = sqlite3_open(p->zDb, &p->db);
@@ -881,10 +892,13 @@
892 blob_appendf(pOut, "Sender: <%s>\r\n", p->zFrom);
893 }else{
894 blob_appendf(pOut, "From: <%s>\r\n", p->zFrom);
895 }
896 blob_appendf(pOut, "Date: %z\r\n", cgi_rfc822_datestamp(time(0)));
897 if( p->zListId && p->zListId[0] ){
898 blob_appendf(pOut, "List-Id: %s\r\n", p->zListId);
899 }
900 if( strstr(blob_str(pHdr), "\r\nMessage-Id:")==0 ){
901 /* Message-id format: "<$(date)x$(random)@$(from-host)>" where $(date) is
902 ** the current unix-time in hex, $(random) is a 64-bit random number,
903 ** and $(from) is the domain part of the email-self setting. */
904 sqlite3_randomness(sizeof(r1), &r1);
@@ -1029,10 +1043,15 @@
1043 /*
1044 ** SETTING: email-self width=40
1045 ** This is the email address for the repository. Outbound emails add
1046 ** this email address as the "From:" field.
1047 */
1048 /*
1049 ** SETTING: email-listid width=40
1050 ** If this setting is not an empty string, then it becomes the argument to
1051 ** a "List-ID:" header that is added to all out-bound notification emails.
1052 */
1053 /*
1054 ** SETTING: email-send-relayhost width=40 sensitive
1055 ** This is the hostname and TCP port to which output email messages
1056 ** are sent when email-send-method is "relay". There should be an
1057 ** SMTP server configured as a Mail Submission Agent listening on the
1058

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button