Fossil SCM
Updates to the email-sender.tcl script.
Commit
334f7f4267193721d3037d8a9d5626e6dcb11ad73ea1f5aa704bde41e9b86a6b
Parent
da9aa4abf726a3e…
1 file changed
+8
-5
+8
-5
| --- tools/email-sender.tcl | ||
| +++ tools/email-sender.tcl | ||
| @@ -3,11 +3,11 @@ | ||
| 3 | 3 | # Monitor the database file named by the DBFILE variable |
| 4 | 4 | # looking for email messages sent by Fossil. Forward each |
| 5 | 5 | # to /usr/sbin/sendmail. |
| 6 | 6 | # |
| 7 | 7 | set POLLING_INTERVAL 10000 ;# milliseconds |
| 8 | -set DBFILE /home/www/fossil/emailqueue.db | |
| 8 | +set DBFILE /home/www/data/emailqueue.db | |
| 9 | 9 | set PIPE "/usr/sbin/sendmail -ti" |
| 10 | 10 | |
| 11 | 11 | package require sqlite3 |
| 12 | 12 | # puts "SQLite version [sqlite3 -version]" |
| 13 | 13 | sqlite3 db $DBFILE |
| @@ -18,13 +18,14 @@ | ||
| 18 | 18 | emailid INTEGER PRIMARY KEY, |
| 19 | 19 | msg TXT |
| 20 | 20 | ); |
| 21 | 21 | } |
| 22 | 22 | while {1} { |
| 23 | + set n 0 | |
| 23 | 24 | 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} { | |
| 26 | 27 | set pipe $PIPE |
| 27 | 28 | if {[regexp {\nFrom:[^\n]*<([^>]+)>} $msg all addr]} { |
| 28 | 29 | append pipe " -f $addr" |
| 29 | 30 | } |
| 30 | 31 | set out [open |$pipe w] |
| @@ -32,10 +33,12 @@ | ||
| 32 | 33 | flush $out |
| 33 | 34 | close $out |
| 34 | 35 | incr n |
| 35 | 36 | } |
| 36 | 37 | if {$n>0} { |
| 37 | - db eval {DELETE FROM email} | |
| 38 | + db eval {DELETE FROM email WHERE emailid=$emailid} | |
| 38 | 39 | } |
| 39 | 40 | } |
| 40 | - after $POLLING_INTERVAL | |
| 41 | + if {$n==0} { | |
| 42 | + after $POLLING_INTERVAL | |
| 43 | + } | |
| 41 | 44 | } |
| 42 | 45 |
| --- 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 |