Greatly improve recipient selection mechanism.

This resolves many errors, such as forwarding loops arising from mailing lists.
This commit is contained in:
perennate 2013-08-09 14:41:06 +08:00 committed by Igor Rzegocki
parent d6aaa9f243
commit f78652ac15
2 changed files with 7 additions and 12 deletions

View File

@ -3,11 +3,11 @@
available in the GPG home directory you use in step 2
2) Configure /etc/gpg-mailgate.conf based on the provided sample config
3) Place gpg-mailgate.py in /usr/local/bin/
4) Place the GnuPG directory in /usr/local/lib/python2.5/site-packages
4) Place the GnuPG directory in /usr/lib/python2.7/ (replace 2.7 with your Python version)
5) Add the following to the end of /etc/postfix/master.cf
gpg-mailgate unix - n n - - pipe
flags= user=nobody argv=/usr/local/bin/gpg-mailgate.py
flags= user=nobody argv=/usr/local/bin/gpg-mailgate.py ${recipient}
127.0.0.1:10028 inet n - n - 10 smtpd
-o content_filter=

View File

@ -22,16 +22,11 @@ for sect in _cfg.sections():
raw = sys.stdin.read()
raw_message = email.message_from_string( raw )
from_addr = raw_message['From']
to_addrs = list()
to_addrs = sys.argv[1:]
encrypted_to_addrs = list()
if raw_message.has_key('To'):
to_addrs.extend( [e[1] for e in email.utils.getaddresses([raw_message['To']])] )
if raw_message.has_key('Cc'):
to_addrs.extend( [e[1] for e in email.utils.getaddresses([raw_message['Cc']])] )
if raw_message.has_key('Bcc'):
to_addrs.extend( [e[1] for e in email.utils.getaddresses([raw_message['Bcc']])] )
if raw_message.has_key('X-GPG-Encrypt-Cc'):
encrypted_to_addrs.extend( [e[1] for e in email.utils.getaddresses([raw_message['X-GPG-Encrypt-Cc']])] )
encrypted_to_addrs.extend( [e[1] for e in email.utils.getaddresses([raw_message['X-GPG-Encrypt-Cc']])] )
del raw_message['X-GPG-Encrypt-Cc']
def send_msg( message, recipients = None ):
@ -85,8 +80,8 @@ for enc in encrypted_to_addrs:
if domain in cfg['default']['domains'].split(','):
if enc in keys:
gpg_to.append( (enc, enc) )
elif cfg.has_key('keymap') and cfg['keymap'].has_key(enc):
gpg_to.append( (enc, cfg['keymap'][enc]) )
elif cfg.has_key('keymap') and cfg['keymap'].has_key(enc):
gpg_to.append( (enc, cfg['keymap'][enc]) )
for to in to_addrs:
domain = to.split('@')[1]