Advertisement
puggan

Mailman-2.1.20/Handlers/CookHeaders.py:131

Apr 18th, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. # Be as robust as possible here.
  2. faddrs = getaddresses(msg.get_all('from', []))
  3. # Strip the nulls and bad emails.
  4. faddrs = [x for x in faddrs if x[1].find('@') > 0]
  5. if len(faddrs) == 1:
  6.     realname, email = o_from = faddrs[0]
  7. else:
  8.     # No From: or multiple addresses.  Just punt and take
  9.     # the get_sender result.
  10.     realname = ''
  11.     email = msgdata['original_sender']
  12.     o_from = (realname, email)
  13. if not realname:
  14.     if mlist.isMember(email):
  15.         realname = mlist.getMemberName(email) or email
  16.     else:
  17.         realname = email
  18. # Remove domain from realname if it looks like an email address
  19. realname = re.sub(r'@([^ .]+\.)+[^ .]+$', '---', realname)
  20. change_header('From',
  21.                 formataddr(('%s via %s' % (realname, mlist.real_name),
  22.                             mlist.GetListEmail())),
  23.                 mlist, msg, msgdata)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement