~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/email_message.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""A convenience class around email.Message and email.MIMEMultipart."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from email import (
22
20
    Header,
23
21
    Message,
33
31
 
34
32
class EmailMessage(object):
35
33
    """An email message.
36
 
 
 
34
    
37
35
    The constructor needs an origin address, a destination address or addresses
38
36
    and a subject, and accepts a body as well. Add additional parts to the
39
37
    message with add_inline_attachment(). Retrieve the entire formatted message
97
95
 
98
96
    def as_string(self, boundary=None):
99
97
        """Return the entire formatted message as a string.
100
 
 
 
98
        
101
99
        :param boundary: The boundary to use between MIME parts, if applicable.
102
100
            Used for tests.
103
101
        """
138
136
 
139
137
    def __getitem__(self, header):
140
138
        """Get a header from the message, returning None if not present.
141
 
 
 
139
        
142
140
        This method intentionally does not raise KeyError to mimic the behavior
143
141
        of __getitem__ in email.Message.
144
142
        """
149
147
 
150
148
    @staticmethod
151
149
    def send(config, from_address, to_address, subject, body, attachment=None,
152
 
             attachment_filename=None, attachment_mime_subtype='plain'):
 
150
            attachment_filename=None, attachment_mime_subtype='plain'):
153
151
        """Create an email message and send it with SMTPConnection.
154
152
 
155
153
        :param config: config object to pass to SMTPConnection constructor.
183
181
    def string_with_encoding(string_):
184
182
        """Return a str object together with an encoding.
185
183
 
186
 
        :param string\\_: A str or unicode object.
 
184
        :param string_: A str or unicode object.
187
185
        :return: A tuple (str, encoding), where encoding is one of 'ascii',
188
186
            'utf-8', or '8-bit', in that preferred order.
189
187
        """