Package lamson :: Module mail :: Class MailResponse
[hide private]
[frames] | no frames]

Class MailResponse

source code


You are given MailResponse objects from the lamson.view methods, and whenever you want to generate an email to send to someone. It has the same basic functionality as MailRequest, but it is designed to be written to, rather than read from (although you can do both).

You can easily set a Body or Html during creation or after by passing it as __init__ parameters, or by setting those attributes.

You can initially set the From, To, and Subject, but they are headers so use the dict notation to change them: msg['From'] = 'joe@test.com'.

The message is not fully crafted until right when you convert it with MailResponse.to_message. This lets you change it and work with it, then send it out when it's ready.

Instance Methods [hide private]
 
__init__(self, To=None, From=None, Subject=None, Body=None, Html=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__contains__(self, key) source code
 
__getitem__(self, key) source code
 
__setitem__(self, key, val) source code
 
__delitem__(self, name) source code
 
attach(self, filename=None, content_type=None, data=None, disposition=None)
Simplifies attaching files from disk or data as files.
source code
 
attach_part(self, part)
Attaches a raw MailBase part from a MailRequest (or anywhere) so that you can copy it over.
source code
 
attach_all_parts(self, mail_request)
Used for copying the attachment parts of a mail.MailRequest object for mailing lists that need to maintain attachments.
source code
 
clear(self)
Clears out the attachments so you can redo them.
source code
 
update(self, message)
Used to easily set a bunch of heading from another dict like object.
source code
 
__str__(self)
Converts to a string.
source code
 
_encode_attachment(self, filename=None, content_type=None, data=None, disposition=None, part=None)
Used internally to take the attachments mentioned in self.attachments and do the actual encoding in a lazy way when you call to_message.
source code
 
to_message(self)
Figures out all the required steps to finally craft the message you need and return it.
source code
 
all_parts(self)
Returns all the encoded parts.
source code
 
keys(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  msg

Inherited from object: __class__

Method Details [hide private]

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

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__contains__(self, key)
(In operator)

source code 

__getitem__(self, key)
(Indexing operator)

source code 

__setitem__(self, key, val)
(Index assignment operator)

source code 

__delitem__(self, name)
(Index deletion operator)

source code 

attach(self, filename=None, content_type=None, data=None, disposition=None)

source code 

Simplifies attaching files from disk or data as files. To attach simple text simple give data and a content_type. To attach a file, give the data/content_type/filename/disposition combination.

For convenience, if you don't give data and only a filename, then it will read that file's contents when you call to_message() later. If you give data and filename then it will assume you've filled data with what the file's contents are and filename is just the name to use.

attach_part(self, part)

source code 

Attaches a raw MailBase part from a MailRequest (or anywhere) so that you can copy it over.

attach_all_parts(self, mail_request)

source code 

Used for copying the attachment parts of a mail.MailRequest object for mailing lists that need to maintain attachments.

clear(self)

source code 

Clears out the attachments so you can redo them. Use this to keep the headers for a series of different messages with different attachments.

update(self, message)

source code 

Used to easily set a bunch of heading from another dict like object.

__str__(self)
(Informal representation operator)

source code 

Converts to a string.

Overrides: object.__str__

_encode_attachment(self, filename=None, content_type=None, data=None, disposition=None, part=None)

source code 

Used internally to take the attachments mentioned in self.attachments and do the actual encoding in a lazy way when you call to_message.

to_message(self)

source code 

Figures out all the required steps to finally craft the message you need and return it. The resulting message is also available as a self.base attribute.

What is returned is a Python email API message you can use with those APIs. The self.base attribute is the raw lamson.encoding.MailBase.

all_parts(self)

source code 

Returns all the encoded parts. Only useful for debugging or inspecting after calling to_message().

keys(self)

source code 

Property Details [hide private]

msg

Get Method:
unreachable.msg(self)