summaryrefslogtreecommitdiff
path: root/oftc-listmod-process-outbox
blob: a0b634d4ba84f2815f55e1e105ea0c6af4aa5bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/ruby

OUTBOX="mail/outbox"
HUMANS="mail/outbox-tolistmods"
HUMAN="listmoderators@lists.oftc.net"

def check_maildir(d)
	throw "#{d} is not a maildir" unless FileTest.directory?(d)
	throw "#{d} is not a maildir" unless FileTest.directory?(d+"/new")
	throw "#{d} is not a maildir" unless FileTest.directory?(d+"/cur")
	throw "#{d} is not a maildir" unless FileTest.directory?(d+"/tmp")
	true
end

check_maildir OUTBOX
check_maildir HUMANS

Dir[OUTBOX+"/new/*"].each do |filename|
	if system("/usr/sbin/sendmail -t -oi < #{filename}")
		File.unlink(filename)
	else
		STDERR.puts "Mailing of #{filename} failed."
	end
end

Dir[HUMANS+"/new/*"].each do |filename|
	if system("/usr/sbin/sendmail -oi #{HUMAN} < #{filename}")
		File.unlink(filename)
	else
		STDERR.puts "Mailing of #{filename} failed."
	end
end