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为:majiye9396@163.com
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为:"majiye9396@163.com" <majiye9396@163.com>
# value = decode_str(value)
# else:
# hdr, addr = parseaddr(value)
# name = decode_str(hdr)
# value = u'%s <%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: ['majiye@fulan.com.cn', 'liuqi1@fulan.com.cn', 'majiye9396@163.com']