Package mailer :: Module mailer :: Class Message
[hide private]

Class Message

source code


Represents an email message.

Set the To, From, Subject, and Body attributes as plain-text strings. Optionally, set the Html attribute to send an HTML email, or use the attach() method to attach files.

Use the charset property to send messages using other than us-ascii

If you specify an attachments argument, it should be a list of attachment filenames: ["file1.txt", "file2.txt"]

`To` should be a string for a single address, and a sequence of strings for multiple recipients (castable to list)

Send using the Mailer class.

Instance Methods [hide private]
 
__init__(self, To=None, From=None, Subject=None, Body=None, Html=None, attachments=None, charset=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
as_string(self)
Get the email as a string to send in the mailer
source code
 
_plaintext(self)
Plain text email with no attachments
source code
 
_with_html(self)
There's an html part
source code
 
_set_info(self, msg) source code
 
_multipart(self)
The email has attachments
source code
 
_add_attachment(self, outer, filename, cid) source code
 
attach(self, filename, cid=None)
Attach a file to the email.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Instance Variables [hide private]
  To
string or iterable
  From
string
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, To=None, From=None, Subject=None, Body=None, Html=None, attachments=None, charset=None)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

attach(self, filename, cid=None)

source code 
Attach a file to the email. Specify the name of the file; Message will figure out the MIME type and load the file.