GMime.Message¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
addrlists |
r |
a table of address lists |
|
date |
r |
Date value |
|
marker |
r |
||
message_id |
r |
Message-Id string |
|
mime_part |
r |
toplevel MIME part |
|
parent_object |
r |
parent |
|
subject |
r |
Subject string |
Class Details¶
- class GMime.Message(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A MIME Message object.
- classmethod new(pretty_headers)¶
- Parameters:
pretty_headers (
bool
) – make pretty headers- Returns:
an empty
GMime.Message
object.- Return type:
If pretty_headers is
True
, then the standard rfc822 headers are initialized so as to put headers in a nice friendly order. This is strictly a cosmetic thing, so if you are unsure, it is safe to say no (False
).
- add_mailbox(type, name, addr)¶
- Parameters:
type (
GMime.AddressType
) – AGMime.AddressType
addr (
str
) – The address of the mailbox
Add a mailbox of a chosen type to the MIME message.
Note: The name (and addr) strings should be in UTF-8.
- foreach(callback, *user_data)¶
- Parameters:
callback (
GMime.ObjectForeachFunc
) – function to call on each of the mime parts contained by the mime message
Recursively calls callback on each of the mime parts in the mime message.
- get_addresses(type)¶
- Parameters:
type (
GMime.AddressType
) – AGMime.AddressType
- Returns:
a list of addresses of the specified type from the self.
- Return type:
Gets a list of addresses of the specified type from the self.
- get_all_recipients()¶
- Returns:
a newly allocated
GMime.InternetAddressList
containing all recipients of the message orNone
if no recipients are set.- Return type:
Gets the complete list of recipients for self.
- get_autocrypt_gossip_headers(now, flags, session_key)¶
- Parameters:
now (
GLib.DateTime
orNone
) – aGLib.DateTime
object, orNone
flags (
GMime.DecryptFlags
) – aGMime.DecryptFlags
, to be used during decryption
- Raises:
- Returns:
a new
GMime.AutocryptHeaderList
object, orNone
on error.- Return type:
Creates a new
GMime.AutocryptHeaderList
of relevant headers of the given type based on the recipient(s) of an e-mail message.Returns the same object as #g_mime_message_get_autocrypt_gossip_headers_with_inner_part , but handles decryption and cleanup automatically.
flags and session_key are passed through to
GMime.MultipartEncrypted.decrypt
, as needed.If the message is not actually an encrypted message, returns
None
: it should be ignored for purposes of evaluating gossip.If decryption fails, returns
None
. In this case, an exception will be set on err to provide information about the decryption failure.
- get_autocrypt_gossip_headers_from_inner_part(now, inner_part)¶
- Parameters:
now (
GLib.DateTime
orNone
) – aGLib.DateTime
object, orNone
inner_part (
GMime.Object
) – aGMime.Object
which is the cleartext part of the inner message
- Returns:
a new
GMime.AutocryptHeaderList
object, orNone
on error.- Return type:
Creates a new
GMime.AutocryptHeaderList
of relevant headers of the given type based on the recipient(s) of an e-mail message.You must pass the decrypted inner part of the message to this function, since Autocrypt-Gossip headers are only stored within the encrypted layer.
If you don’t already have the decrypted inner part available to you, you probably want to use
GMime.Message.get_autocrypt_gossip_headers
instead.Each header in the returned list will:
have a valid address
be of the type requested
be complete
If no Autocrypt header is found for a recipient, no
GMime.AutocryptHeader
will be in the list associated with that e-mail address.Note that the following types of Autocrypt headers will not be returned by this function:
headers of an unrequested type
headers that do not match an address in “From:”
unparseable headers
headers with unknown critical attributes
duplicate valid headers for a given address
On error (e.g. if this version of GMime cannot handle the requested Autocrypt type, or if a parameter is missing or malformed), returns
None
The returned Autocrypt headers will have their effective_date set to the earliest of either:
the Date: header of the message or
now (or the current time, if now is
None
)
- get_autocrypt_header(now)¶
- Parameters:
now (
GLib.DateTime
orNone
) – aGLib.DateTime
object, orNone
- Returns:
a new
GMime.AutocryptHeader
object, orNone
if the message should be ignored for purposes of Autocrypt.- Return type:
Creates a new
GMime.AutocryptHeader
based on the relevant Autocrypt header associated with the sender of an e-mail message.If the message has no sender in the From: field, or has more than one sender, then this function will return
None
. Autocrypt should ignore the message entirely.If there is one sender, but no single Autocrypt header is found that matches that e-mail address, a
GMime.AutocryptHeader
will be returned for the sender, but it will be incomplete (seeGMime.AutocryptHeader.is_complete
).Note that the following types of Autocrypt headers will not be returned by this function:
headers that do not match an address in “From:”
unparseable headers
headers with unknown critical attributes
duplicate valid headers for the sender’s address
The returned Autocrypt header will have its effective_date set to the earliest of either:
the Date: header of the message or
now (or the current time, if now is
None
)
- get_bcc()¶
- Returns:
the parsed list of addresses in the Bcc header(s).
- Return type:
Gets combined list of parsed addresses in the Bcc header(s).
- get_body()¶
- Returns:
a
GMime.Object
containing the textual content that appears to be the main body of the message, orNone
if no body part has been set.Note: This function is NOT guaranteed to always work as it makes some assumptions that are not necessarily true. It is recommended that you traverse the MIME structure yourself.
- Return type:
GMime.Object
orNone
Attempts to identify the MIME part containing the body of the message.
- get_cc()¶
- Returns:
the parsed list of addresses in the Cc header(s).
- Return type:
Gets combined list of parsed addresses in the Cc header(s).
- get_date()¶
- Returns:
a
GLib.DateTime
on success orNone
if the date could not be parsed.- Return type:
Gets the parsed date and time value from the Date header.
- get_from()¶
- Returns:
the parsed list of addresses in the From header.
- Return type:
Gets the parsed list of addresses in the From header.
- get_message_id()¶
-
Gets the Message-Id header of self.
- get_mime_part()¶
- Returns:
the toplevel MIME part of self, or
None
if none is present.- Return type:
GMime.Object
orNone
Gets the toplevel MIME part contained within self.
- get_reply_to()¶
- Returns:
the parsed list of addresses in the Reply-To header.
- Return type:
Gets the parsed list of addresses in the Reply-To header.
- get_sender()¶
- Returns:
the parsed list of addresses in the Sender header.
- Return type:
Gets the parsed list of addresses in the Sender header.
- get_subject()¶
- Returns:
the subject of the self in a form suitable for display or
None
if no subject is set. If notNone
, the returned string will be in UTF-8.- Return type:
Gets the subject of the self.
- get_to()¶
- Returns:
the parsed list of addresses in the To header(s).
- Return type:
Gets combined list of parsed addresses in the To header(s).
- partial_split_message(max_size)¶
- Parameters:
max_size (
int
) – max size- Returns:
an array of
GMime.Message
objects and sets nparts to the number of messages returned orNone
on fail.- Return type:
[
GMime.Message
] orNone
Splits self into an array of
GMime.Message
objects each containing a singleGMime.MessagePartial
object containing max_size bytes or fewer. nparts is set to the number ofGMime.MessagePartial
objects created.
- set_date(date)¶
- Parameters:
date (
GLib.DateTime
) – a date to be used in the Date header
Sets the Date header on a MIME Message.
- set_message_id(message_id)¶
- Parameters:
message_id (
str
) – message-id (addr-spec portion)
Set the Message-Id on a message.
- set_mime_part(mime_part)¶
- Parameters:
mime_part (
GMime.Object
) – The root-level MIME Part
Set the root-level MIME part of the message.