to_addrs not defined if 'To' header is non-existant

This commit is contained in:
mcmaster 2010-01-20 16:26:20 -05:00
parent 86cdbf7a4e
commit ea5e0c2ae6
1 changed files with 4 additions and 3 deletions

View File

@ -19,12 +19,13 @@ for sect in _cfg.sections():
raw = sys.stdin.read()
raw_message = email.message_from_string( raw )
from_addr = raw_message['From']
to_addrs = list()
if raw_message.has_key('To'):
to_addrs = map(lambda x: x.strip(), raw_message['To'].split(','))
to_addrs.extend( map(lambda x: x.strip(), raw_message['To'].split(',')) )
if raw_message.has_key('Cc'):
to_addrs.extend( map(lambda x: x.strip(), raw_message['Cc'].split(',')))
to_addrs.extend( map(lambda x: x.strip(), raw_message['Cc'].split(',')) )
if raw_message.has_key('Bcc'):
to_addrs.extend( map(lambda x: x.strip(), raw_message['Bcc'].split(',')))
to_addrs.extend( map(lambda x: x.strip(), raw_message['Bcc'].split(',')) )
def send_msg( message, recipients = None ):
if recipients == None: