chiark
/
gitweb
/
~mdw
/
newsgate
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mail: Send mail with the correct envelope sender.
[newsgate]
/
bin
/
inject
diff --git
a/bin/inject
b/bin/inject
index 6dbfdb3ac62ebc68269ff4b0c285b33c90b8323c..f6e360bc1cf9ef15762ea116776c93d326943c02 100755
(executable)
--- a/
bin/inject
+++ b/
bin/inject
@@
-7,6
+7,7
@@
import socket as S
from getopt import getopt, GetoptError
from sys import stdin, stdout, stderr, argv, exit
from cStringIO import StringIO
from getopt import getopt, GetoptError
from sys import stdin, stdout, stderr, argv, exit
from cStringIO import StringIO
+env = OS.environ
prog = argv[0]
prog = argv[0]
@@
-51,13
+52,16
@@
except:
host = 'localhost'
dist = 'mail'
path = 'newsgate'
host = 'localhost'
dist = 'mail'
path = 'newsgate'
+sender = env.get('SENDER')
+recip = env.get('RECIPIENT')
group = None
def opts():
group = None
def opts():
- global approved, remote, host, dist, path, group
+ global approved, remote, host, dist, path, group
, sender, recip
try:
try:
- opts, args = getopt(argv[1:], 'a:d:h:r:p:',
+ opts, args = getopt(argv[1:], 'a:d:h:r:p:
S:R:
',
['approved=', 'distribution=',
['approved=', 'distribution=',
+ 'sender=', 'recipient=',
'hostname=', 'remote=', 'path='])
except GetoptError:
usage()
'hostname=', 'remote=', 'path='])
except GetoptError:
usage()
@@
-70,6
+74,10
@@
def opts():
host = a
elif o in ('-r', '--remote'):
remote = (lambda addr, port = 119: (addr, int(port)))(*a.split(':'))
host = a
elif o in ('-r', '--remote'):
remote = (lambda addr, port = 119: (addr, int(port)))(*a.split(':'))
+ elif o in ('-R', '--recipient'):
+ recip = a
+ elif o in ('-S', '--sender'):
+ sender = a
if len(args) != 1:
usage()
group, = args
if len(args) != 1:
usage()
group, = args
@@
-104,8
+112,10
@@
def send():
hdr.write('Path: newsgate\r\n'
'Distribution: mail\r\n'
'Newsgroups: %s\r\n'
hdr.write('Path: newsgate\r\n'
'Distribution: mail\r\n'
'Newsgroups: %s\r\n'
- 'Approved: %s\r\n'
- % (group, approved or 'newsgate@%s' % host))
+ % group)
+ if approved: hdr.write('Approved: %s\r\n' % approved)
+ if sender: hdr.write('Return-Path: <%s>\r\n' % sender)
+ if recip: hdr.write('Delivered-To: %s\r\n' % recip)
xify = {}
for h in '''
lines xref newsgroups path distribution approved received
xify = {}
for h in '''
lines xref newsgroups path distribution approved received