Fossil SCM

Updates to the email-sender.tcl script.

drh 2025-10-23 11:24 trunk
Commit 334f7f4267193721d3037d8a9d5626e6dcb11ad73ea1f5aa704bde41e9b86a6b
1 file changed +8 -5
--- tools/email-sender.tcl
+++ tools/email-sender.tcl
@@ -3,11 +3,11 @@
33
# Monitor the database file named by the DBFILE variable
44
# looking for email messages sent by Fossil. Forward each
55
# to /usr/sbin/sendmail.
66
#
77
set POLLING_INTERVAL 10000 ;# milliseconds
8
-set DBFILE /home/www/fossil/emailqueue.db
8
+set DBFILE /home/www/data/emailqueue.db
99
set PIPE "/usr/sbin/sendmail -ti"
1010
1111
package require sqlite3
1212
# puts "SQLite version [sqlite3 -version]"
1313
sqlite3 db $DBFILE
@@ -18,13 +18,14 @@
1818
emailid INTEGER PRIMARY KEY,
1919
msg TXT
2020
);
2121
}
2222
while {1} {
23
+ set n 0
2324
db transaction immediate {
24
- set n 0
25
- db eval {SELECT msg FROM email} {
25
+ set emailid 0
26
+ db eval {SELECT emailid, msg FROM email LIMIT 1} {
2627
set pipe $PIPE
2728
if {[regexp {\nFrom:[^\n]*<([^>]+)>} $msg all addr]} {
2829
append pipe " -f $addr"
2930
}
3031
set out [open |$pipe w]
@@ -32,10 +33,12 @@
3233
flush $out
3334
close $out
3435
incr n
3536
}
3637
if {$n>0} {
37
- db eval {DELETE FROM email}
38
+ db eval {DELETE FROM email WHERE emailid=$emailid}
3839
}
3940
}
40
- after $POLLING_INTERVAL
41
+ if {$n==0} {
42
+ after $POLLING_INTERVAL
43
+ }
4144
}
4245
--- tools/email-sender.tcl
+++ tools/email-sender.tcl
@@ -3,11 +3,11 @@
3 # Monitor the database file named by the DBFILE variable
4 # looking for email messages sent by Fossil. Forward each
5 # to /usr/sbin/sendmail.
6 #
7 set POLLING_INTERVAL 10000 ;# milliseconds
8 set DBFILE /home/www/fossil/emailqueue.db
9 set PIPE "/usr/sbin/sendmail -ti"
10
11 package require sqlite3
12 # puts "SQLite version [sqlite3 -version]"
13 sqlite3 db $DBFILE
@@ -18,13 +18,14 @@
18 emailid INTEGER PRIMARY KEY,
19 msg TXT
20 );
21 }
22 while {1} {
 
23 db transaction immediate {
24 set n 0
25 db eval {SELECT msg FROM email} {
26 set pipe $PIPE
27 if {[regexp {\nFrom:[^\n]*<([^>]+)>} $msg all addr]} {
28 append pipe " -f $addr"
29 }
30 set out [open |$pipe w]
@@ -32,10 +33,12 @@
32 flush $out
33 close $out
34 incr n
35 }
36 if {$n>0} {
37 db eval {DELETE FROM email}
38 }
39 }
40 after $POLLING_INTERVAL
 
 
41 }
42
--- tools/email-sender.tcl
+++ tools/email-sender.tcl
@@ -3,11 +3,11 @@
3 # Monitor the database file named by the DBFILE variable
4 # looking for email messages sent by Fossil. Forward each
5 # to /usr/sbin/sendmail.
6 #
7 set POLLING_INTERVAL 10000 ;# milliseconds
8 set DBFILE /home/www/data/emailqueue.db
9 set PIPE "/usr/sbin/sendmail -ti"
10
11 package require sqlite3
12 # puts "SQLite version [sqlite3 -version]"
13 sqlite3 db $DBFILE
@@ -18,13 +18,14 @@
18 emailid INTEGER PRIMARY KEY,
19 msg TXT
20 );
21 }
22 while {1} {
23 set n 0
24 db transaction immediate {
25 set emailid 0
26 db eval {SELECT emailid, msg FROM email LIMIT 1} {
27 set pipe $PIPE
28 if {[regexp {\nFrom:[^\n]*<([^>]+)>} $msg all addr]} {
29 append pipe " -f $addr"
30 }
31 set out [open |$pipe w]
@@ -32,10 +33,12 @@
33 flush $out
34 close $out
35 incr n
36 }
37 if {$n>0} {
38 db eval {DELETE FROM email WHERE emailid=$emailid}
39 }
40 }
41 if {$n==0} {
42 after $POLLING_INTERVAL
43 }
44 }
45

Keyboard Shortcuts

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