Artifact 68217a0707268b570bd2f78e1799ae86c5cb0cc4e7eac321963fa24b6305c446:
- Executable file
tools/email-sender.tcl
— part of check-in
[a52499fdc4]
at
2020-05-28 15:46:29
on branch trunk
— Updates the email-sender TCL script so that it appends a "-f" argument
to sendmail which is the "From:" email address.
(user:
drh
size: 940)
[more...]
#!/usr/bin/tcl
#
# Monitor the database file named by the DBFILE variable
# looking for email messages sent by Fossil. Forward each
# to /usr/sbin/sendmail.
#
set POLLING_INTERVAL 10000 ;# milliseconds
set DBFILE /home/www/fossil/emailqueue.db
set PIPE "/usr/sbin/sendmail -ti"
package require sqlite3
# puts "SQLite version [sqlite3 -version]"
sqlite3 db $DBFILE
db timeout 5000
catch {db eval {PRAGMA journal_mode=WAL}}
db eval {
CREATE TABLE IF NOT EXISTS email(
emailid INTEGER PRIMARY KEY,
msg TXT
);
}
while {1} {
db transaction immediate {
set n 0
db eval {SELECT msg FROM email} {
set pipe $PIPE
if {[regexp {\nFrom:[^\n]*<([^>]+)>} $msg all addr]} {
append pipe " -f $addr"
}
set out [open |$pipe w]
puts -nonewline $out $msg
flush $out
close $out
incr n
}
if {$n>0} {
db eval {DELETE FROM email}
}
}
after $POLLING_INTERVAL
}