~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smtp_connection.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-28 07:08:27 UTC
  • mfrom: (2553.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070628070827-h5s313dg5tnag9vj
(robertc) Show the names of commit hooks during commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    def get_message_addresses(message):
80
80
        """Get the origin and destination addresses of a message.
81
81
 
82
 
        :param message: A message object supporting get() to access its
83
 
            headers, like email.Message or bzrlib.email_message.EmailMessage.
 
82
        :param message: An email.Message or email.MIMEMultipart object.
84
83
        :return: A pair (from_email, to_emails), where from_email is the email
85
84
            address in the From header, and to_emails a list of all the
86
85
            addresses in the To, Cc, and Bcc headers.
87
86
        """
88
 
        from_email = Utils.parseaddr(message.get('From', None))[1]
 
87
        from_email = Utils.parseaddr(message['From'])[1]
89
88
        to_full_addresses = []
90
89
        for header in ['To', 'Cc', 'Bcc']:
91
 
            value = message.get(header, None)
92
 
            if value:
93
 
                to_full_addresses.append(value)
 
90
            to_full_addresses += message.get_all(header, [])
94
91
        to_emails = [ pair[1] for pair in
95
92
                Utils.getaddresses(to_full_addresses) ]
96
93