def print_info(msg, log, indent=0):
if indent == 0:
send_email_to = []
send_email_cc = []
for header in ['From', 'To', 'Cc']:
value = msg.get(header, '')
# 获取原始的发件人 发送给谁 抄送人
# 解析的emailAdr为:[emailprotected]
if value:
value01 = value.split(', ')
for item in value01:
emailRealName, emailAdr = parseaddr(item)
if header == 'From' or header == 'To':
send_email_to.append(emailAdr)
elif header == 'Cc':
send_email_cc.append(emailAdr)
else:
pass
# if value:
# # 解析的value为:"[emailprotected]"
# value = decode_str(value)
# else:
# hdr, addr = parseaddr(value)
# name = decode_str(hdr)
# value = u'%s ' % (name, addr)
# log.info('%s%s: %s' % (' ' * indent, header, value))
log.info('收件人: %s' % send_email_to)
log.info('抄送人人: %s' % send_email_cc)
# send_email_to: ['[emailprotected]', '[emailprotected]', '[emailprotected]']
原文:/We612/p/12072918.html