GMimeMessage

GMimeMessage — Messages

Functions

GMimeMessage * g_mime_message_new ()
GMimeMessage * g_mime_message_load ()
GMimeMessage * g_mime_message_load_with_storage ()
GMimeMessage * g_mime_message_load_from_file ()
ssize_t g_mime_message_write_headers_to_stream ()
GMimeInternetAddressList * g_mime_message_get_sender ()
GMimeInternetAddressList * g_mime_message_get_from ()
GMimeInternetAddressList * g_mime_message_get_reply_to ()
GMimeInternetAddressList * g_mime_message_get_to ()
GMimeInternetAddressList * g_mime_message_get_cc ()
GMimeInternetAddressList * g_mime_message_get_bcc ()
GMimeInternetAddressList * g_mime_message_get_resent_from ()
GMimeInternetAddressList * g_mime_message_get_resent_reply_to ()
GMimeInternetAddressList * g_mime_message_get_resent_to ()
GMimeInternetAddressList * g_mime_message_get_resent_cc ()
GMimeInternetAddressList * g_mime_message_get_resent_bcc ()
GMimeInternetAddressList * g_mime_message_get_resent_sender ()
gboolean g_mime_message_add_mailbox ()
GMimeInternetAddressList * g_mime_message_get_addresses ()
GMimeInternetAddressList * g_mime_message_get_all_recipients ()
GMimeInternetAddressList * g_mime_message_get_recipients ()
void g_mime_message_set_importance ()
GMimeMessageImportance g_mime_message_get_importance ()
void g_mime_message_set_priority ()
GMimeMessagePriority g_mime_message_get_priority ()
void g_mime_message_set_x_priority ()
GMimeXMessagePriority g_mime_message_get_x_priority ()
void g_mime_message_set_subject ()
const char * g_mime_message_get_subject ()
void g_mime_message_set_date ()
GDateTime * g_mime_message_get_date ()
void g_mime_message_set_resent_date ()
GDateTime * g_mime_message_get_resent_date ()
void g_mime_message_set_message_id ()
const char * g_mime_message_get_message_id ()
void g_mime_message_set_in_reply_to ()
const char * g_mime_message_get_in_reply_to ()
void g_mime_message_set_resent_message_id ()
const char * g_mime_message_get_resent_message_id ()
GMimeMessageIdList * g_mime_message_get_references ()
void g_mime_message_set_mime_part ()
GMimeEntity * g_mime_message_get_mime_part ()
GPtrArray * g_mime_message_get_body_parts ()
GPtrArray * g_mime_message_get_attachments ()
gboolean g_mime_message_try_get_entity ()
void g_mime_message_foreach ()
GMimeEntity * g_mime_message_get_body ()
char * g_mime_message_get_text_body ()
char * g_mime_message_get_html_body ()
char * g_mime_message_get_text_body_with_format ()
GMimeAutocryptHeader * g_mime_message_get_autocrypt_header ()
GMimeAutocryptHeaderList * g_mime_message_get_autocrypt_gossip_headers_from_inner_part ()
GMimeAutocryptHeaderList * g_mime_message_get_autocrypt_gossip_headers ()

Types and Values

Description

A GMimeMessage represents an rfc822 message. Message header values are parsed on demand and cached until their headers change. Address lists are also allocated on demand. Reading metadata does not rewrite raw headers.

Changed or removed address headers clear a previously returned list; the next message getter reloads that same list. Appending a header extends an already loaded list. References are cleared on any References header change and reloaded by g_mime_message_get_references(). Reacquire these lists through the message after editing raw headers. Editing a retained list instead makes its contents authoritative and updates the corresponding headers.

The legacy parser warning callback requires eager address parsing to retain its existing warning timing. Compliance logging is independent of lazy metadata and continues to report issues during parsing.

Functions

g_mime_message_new ()

GMimeMessage *
g_mime_message_new (gboolean pretty_headers);

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).

Parameters

pretty_headers

make pretty headers

 

Returns

an empty GMimeMessage object.


g_mime_message_load ()

GMimeMessage *
g_mime_message_load (GMimeParserOptions *options,
                     GMimeStream *stream,
                     GError **error);

Loads a message, copying its content into memory. An optional leading UTF-8 byte-order mark is consumed. The input need not support seeking and is neither reset nor closed. The returned message remains usable after stream is closed, modified or released.

Empty input is a parse error. This loads a single MIME message, not an mbox or MMDF mailbox; use GMimeParser for mailbox input.

Parameters

options

parser options, or NULL for defaults.

[nullable]

stream

the input stream at the start of the message

 

error

return location for a GError, or NULL

 

Returns

the message, or NULL on failure.

[nullable][transfer full]


g_mime_message_load_with_storage ()

GMimeMessage *
g_mime_message_load_with_storage (GMimeParserOptions *options,
                                  GMimeStream *stream,
                                  GMimeContentStorage storage,
                                  GError **error);

Loads a message using the requested content storage. Memory storage behaves like g_mime_message_load(). Source storage references leaf content through substreams and requires working tell, seek and substream operations. Seekability is checked with a zero-offset seek from the current position before reading. Unsupported operations and I/O failures report GMIME_ERROR rather than falling back to memory.

The caller owns stream in both modes. With source storage, keep it open and unchanged while parsed content is in use. Content views retain it; releasing the message does not close a stream still owned by the caller. An optional leading UTF-8 byte-order mark is consumed. Empty input is a parse error. The stream is neither reset nor closed.

Parameters

options

parser options, or NULL for defaults.

[nullable]

stream

input positioned at the start of the message

 

storage

storage for parsed MIME part content

 

error

return location for a GError, or NULL

 

Returns

the message, or NULL on failure.

[nullable][transfer full]


g_mime_message_load_from_file ()

GMimeMessage *
g_mime_message_load_from_file (GMimeParserOptions *options,
                               const char *filename,
                               GError **error);

Loads a message from filename using g_mime_message_load(). The file is opened for reading and closed before returning, on success or failure. Content is copied into memory and does not retain the file. Open, read, parse and close failures return NULL with error set.

Parameters

options

parser options, or NULL for defaults.

[nullable]

filename

the input file path.

[type filename]

error

return location for a GError, or NULL

 

Returns

the message, or NULL on failure.

[nullable][transfer full]


g_mime_message_write_headers_to_stream ()

ssize_t
g_mime_message_write_headers_to_stream
                               (GMimeMessage *message,
                                GMimeFormatOptions *options,
                                GMimeStream *stream);

Writes the message headers, merged with the body's headers when present, and the blank line separating headers from content. A parsed message without a separator retains that state, as in full-message output.

Unlike g_mime_entity_get_headers(), this includes the header/body separator when present. It does not read or serialize the body, invoke its virtual writer, or apply body newline completion. The caller's output stream remains open.

Parameters

message

a GMimeMessage

 

options

formatting options, or NULL for defaults.

[nullable]

stream

the output stream

 

Returns

the number of bytes written, or -1 on failure.


g_mime_message_get_sender ()

GMimeInternetAddressList *
g_mime_message_get_sender (GMimeMessage *message);

Gets the persistent list of addresses from all Sender headers, preserving mailboxes and groups. Missing headers yield an empty list. Header edits invalidate the list until the next message getter; list and nested address edits rewrite the Sender header. Clearing the list removes all Sender headers.

This is the same list returned by g_mime_message_get_addresses() with GMIME_ADDRESS_TYPE_SENDER. This intentionally differs from MimeKit's single-mailbox Sender property to support group syntax.

Parameters

message

A GMimeMessage

 

Returns

the Sender address list.

[transfer none]


g_mime_message_get_from ()

GMimeInternetAddressList *
g_mime_message_get_from (GMimeMessage *message);

Gets the parsed list of addresses in the From header.

Parameters

message

A GMimeMessage

 

Returns

the parsed list of addresses in the From header.

[transfer none]


g_mime_message_get_reply_to ()

GMimeInternetAddressList *
g_mime_message_get_reply_to (GMimeMessage *message);

Gets the parsed list of addresses in the Reply-To header.

Parameters

message

A GMimeMessage

 

Returns

the parsed list of addresses in the Reply-To header.

[transfer none]


g_mime_message_get_to ()

GMimeInternetAddressList *
g_mime_message_get_to (GMimeMessage *message);

Gets combined list of parsed addresses in the To header(s).

Parameters

message

A GMimeMessage

 

Returns

the parsed list of addresses in the To header(s).

[transfer none]


g_mime_message_get_cc ()

GMimeInternetAddressList *
g_mime_message_get_cc (GMimeMessage *message);

Gets combined list of parsed addresses in the Cc header(s).

Parameters

message

A GMimeMessage

 

Returns

the parsed list of addresses in the Cc header(s).

[transfer none]


g_mime_message_get_bcc ()

GMimeInternetAddressList *
g_mime_message_get_bcc (GMimeMessage *message);

Gets combined list of parsed addresses in the Bcc header(s).

Parameters

message

A GMimeMessage

 

Returns

the parsed list of addresses in the Bcc header(s).

[transfer none]


g_mime_message_get_resent_from ()

GMimeInternetAddressList *
g_mime_message_get_resent_from (GMimeMessage *message);

Gets the persistent, mutable list combining all Resent-From headers in header order. Raw-header edits clear this same list for lazy reloading by the next message getter, without rewriting the headers. List and nested address changes replace matching headers; emptying the list removes them all. A retained list is safe to use after the message is finalized and no longer updates the message.

Parameters

message

a GMimeMessage

 

Returns

the resent authors.

[transfer none]


g_mime_message_get_resent_reply_to ()

GMimeInternetAddressList *
g_mime_message_get_resent_reply_to (GMimeMessage *message);

Gets the persistent, mutable list combining all Resent-Reply-To headers. Changes to the list update the header, removing it when empty.

Parameters

message

a GMimeMessage

 

Returns

the resent reply addresses.

[transfer none]


g_mime_message_get_resent_to ()

GMimeInternetAddressList *
g_mime_message_get_resent_to (GMimeMessage *message);

Gets the persistent, mutable list combining all Resent-To headers. Changes to the list update the header, removing it when empty.

Parameters

message

a GMimeMessage

 

Returns

the resent primary recipients.

[transfer none]


g_mime_message_get_resent_cc ()

GMimeInternetAddressList *
g_mime_message_get_resent_cc (GMimeMessage *message);

Gets the persistent, mutable list combining all Resent-Cc headers. Changes to the list update the header, removing it when empty.

Parameters

message

a GMimeMessage

 

Returns

the resent secondary recipients.

[transfer none]


g_mime_message_get_resent_bcc ()

GMimeInternetAddressList *
g_mime_message_get_resent_bcc (GMimeMessage *message);

Gets the persistent, mutable list combining all Resent-Bcc headers. Changes to the list update the header, removing it when empty.

Parameters

message

a GMimeMessage

 

Returns

the resent blind-copy recipients.

[transfer none]


g_mime_message_get_resent_sender ()

GMimeInternetAddressList *
g_mime_message_get_resent_sender (GMimeMessage *message);

Gets the persistent list of addresses from all Resent-Sender headers, preserving mailboxes and groups. Missing headers yield an empty list. Header edits invalidate the list until the next message getter; list and nested address edits rewrite the Resent-Sender header. Clearing the list removes all matching headers.

This is the same list returned by g_mime_message_get_addresses() with GMIME_ADDRESS_TYPE_RESENT_SENDER. This intentionally differs from MimeKit's single-mailbox ResentSender property to support group syntax.

Parameters

message

a GMimeMessage

 

Returns

the Resent-Sender address list.

[transfer none]


g_mime_message_add_mailbox ()

gboolean
g_mime_message_add_mailbox (GMimeMessage *message,
                            GMimeAddressType type,
                            const char *name,
                            const char *addr,
                            GError **error);

Add a mailbox of a chosen type to the MIME message.

Note: The name (and addr ) strings should be in UTF-8.

Parameters

message

A GMimeMessage

 

type

A GMimeAddressType

 

name

The name of the mailbox (or NULL).

[nullable]

addr

The address of the mailbox

 

error

return location for a GError.

[nullable]

Returns

whether the mailbox was valid and added.


g_mime_message_get_addresses ()

GMimeInternetAddressList *
g_mime_message_get_addresses (GMimeMessage *message,
                              GMimeAddressType type);

Gets a list of addresses of the specified type from the message . The list is allocated and parsed on first access. Changed or removed headers clear it for reloading by the next message getter; the list object remains the same. List edits update the headers without requiring a getter.

Parameters

message

A GMimeMessage

 

type

A GMimeAddressType

 

Returns

a list of addresses of the specified type from the message .

[transfer none]


g_mime_message_get_all_recipients ()

GMimeInternetAddressList *
g_mime_message_get_all_recipients (GMimeMessage *message);

Combines the ordinary To, Cc, and Bcc lists, preserving groups and duplicates. This legacy accessor does not select resent recipients; use g_mime_message_get_recipients() for MimeKit-style recipient selection.

Parameters

message

A GMimeMessage

 

Returns

a newly allocated GMimeInternetAddressList containing all recipients of the message or NULL if no recipients are set.

[transfer full]


g_mime_message_get_recipients ()

GMimeInternetAddressList *
g_mime_message_get_recipients (GMimeMessage *message,
                               gboolean only_unique);

Gets a mailbox-only snapshot in To, Cc, then Bcc order, flattening groups depth-first. If the Resent-Sender or Resent-From address list is nonempty, only Resent-To, Resent-Cc, and Resent-Bcc are used, even when they contain no mailboxes. Merely having resent recipient headers does not select them.

With only_unique , local parts remain case-sensitive and domains are IDN-encoded and converted to ASCII lowercase, as in address ordering. Domainless addresses are compared as stored. Display names and source routes do not affect deduplication. The first original mailbox instance wins.

The result owns references to original mailboxes, not clones. Its membership is independent of the message, but edits to shared mailboxes are visible through the original address lists.

Parameters

message

a GMimeMessage

 

only_unique

whether to include only the first mailbox for each address

 

Returns

a newly allocated list containing only mailboxes, which is empty when there are no selected recipients.

[transfer full]


g_mime_message_set_importance ()

void
g_mime_message_set_importance (GMimeMessage *message,
                               GMimeMessageImportance importance);

Sets the Importance header to low, normal, or high. Assigning the current importance preserves a single raw header; duplicates are replaced. Invalid enum values are programming errors and leave the message unchanged.

Parameters

message

a GMimeMessage

 

importance

the message importance

 

g_mime_message_get_importance ()

GMimeMessageImportance
g_mime_message_get_importance (GMimeMessage *message);

Parameters

message

a GMimeMessage

 

Returns

the first Importance header's value, or GMIME_MESSAGE_IMPORTANCE_NORMAL if absent or unrecognized.


g_mime_message_set_priority ()

void
g_mime_message_set_priority (GMimeMessage *message,
                             GMimeMessagePriority priority);

Sets the Priority header to non-urgent, normal, or urgent. Assigning the current priority preserves a single raw header; duplicates are replaced. Invalid enum values are programming errors and leave the message unchanged.

Parameters

message

a GMimeMessage

 

priority

the message priority

 

g_mime_message_get_priority ()

GMimeMessagePriority
g_mime_message_get_priority (GMimeMessage *message);

Parameters

message

a GMimeMessage

 

Returns

the first Priority header's value, or GMIME_MESSAGE_PRIORITY_NORMAL if absent or unrecognized.


g_mime_message_set_x_priority ()

void
g_mime_message_set_x_priority (GMimeMessage *message,
                               GMimeXMessagePriority priority);

Sets the X-Priority header to its numeric value and descriptive label. Assigning the current priority preserves a single raw header; duplicates are replaced. Invalid enum values are programming errors and leave the message unchanged.

Parameters

message

a GMimeMessage

 

priority

the message's numeric priority

 

g_mime_message_get_x_priority ()

GMimeXMessagePriority
g_mime_message_get_x_priority (GMimeMessage *message);

Parses an unsigned decimal prefix from the first raw X-Priority header after ASCII folding whitespace. Values are clamped to 1 through 5; missing digits and Int32 overflow yield normal priority.

Parameters

message

a GMimeMessage

 

Returns

the numeric priority, or GMIME_X_MESSAGE_PRIORITY_NORMAL if the header is absent or invalid.


g_mime_message_set_subject ()

void
g_mime_message_set_subject (GMimeMessage *message,
                            const char *subject,
                            const char *charset);

Set the subject of a message .

Note: The subject string should be in UTF-8.

Parameters

message

A GMimeMessage

 

subject

Subject string

 

charset

The charset to use for encoding the subject or NULL to use the default.

[nullable]

g_mime_message_get_subject ()

const char *
g_mime_message_get_subject (GMimeMessage *message);

Gets the decoded value of the first Subject header. Decoding is deferred until the value is requested and cached by the header. Reading the subject does not change the stored raw header or notify header-list observers.

Parameters

message

A GMimeMessage

 

Returns

the subject of the message in a form suitable for display or NULL if no subject is set. If not NULL, the returned string will be in UTF-8.

[nullable]


g_mime_message_set_date ()

void
g_mime_message_set_date (GMimeMessage *message,
                         GDateTime *date);

Sets the Date header on a MIME Message. The message retains date , including its timezone and microseconds; the header represents whole seconds. Assigning the same instant as an already loaded value preserves the cached value and raw header unless duplicate Date headers need to be replaced. A NULL date is a programming error.

Parameters

message

A GMimeMessage

 

date

a date to be used in the Date header

 

g_mime_message_get_date ()

GDateTime *
g_mime_message_get_date (GMimeMessage *message);

Gets the lazily parsed date and time value. Raw header edits invalidate the cache; the next getter parses the first Date header without decoding encoded words or falling back to duplicates.

Parameters

message

A GMimeMessage

 

Returns

a GDateTime on success or NULL if the date could not be parsed.

[nullable][transfer none]


g_mime_message_set_resent_date ()

void
g_mime_message_set_resent_date (GMimeMessage *message,
                                GDateTime *date);

Sets the Resent-Date header independently of Date. The message retains date , including its timezone and microseconds; the header represents whole seconds. Assigning the same instant as an already loaded value preserves the cached value, raw header, and any duplicates. Changed values update only the first Resent-Date header, preserving older resent blocks. A NULL date is a programming error.

Parameters

message

a GMimeMessage

 

date

a date to be used in the Resent-Date header

 

g_mime_message_get_resent_date ()

GDateTime *
g_mime_message_get_resent_date (GMimeMessage *message);

Gets the lazily parsed resent date and time. Raw header edits invalidate the cache; the next getter parses the first Resent-Date header without decoding encoded words or falling back to duplicates.

Parameters

message

a GMimeMessage

 

Returns

the resent date and time, or NULL if the header is absent or invalid.

[nullable][transfer none]


g_mime_message_set_message_id ()

void
g_mime_message_set_message_id (GMimeMessage *message,
                               const char *message_id);

Sets the Message-Id after normalizing a complete message-id. Invalid values, including empty IDs, extra tokens, and non-folding line breaks, are programming errors and leave the message unchanged. Assigning the already loaded ID preserves a single raw header; duplicates are replaced.

Parameters

message

A GMimeMessage

 

message_id

a UTF-8 message-id, with or without angle brackets

 

g_mime_message_get_message_id ()

const char *
g_mime_message_get_message_id (GMimeMessage *message);

Gets the Message-Id header of message .

Parameters

message

A GMimeMessage

 

Returns

the Message-Id of a message, or NULL if not specified.

[nullable]


g_mime_message_set_in_reply_to ()

void
g_mime_message_set_in_reply_to (GMimeMessage *message,
                                const char *message_id);

Sets the In-Reply-To header after normalizing a complete message-id. Invalid values are programming errors and leave the message unchanged. Assigning the already loaded ID preserves a single raw header; duplicates are replaced. A NULL value removes all In-Reply-To headers, including malformed duplicates.

Parameters

message

a GMimeMessage

 

message_id

a UTF-8 message-id, with or without angle brackets.

[nullable]

g_mime_message_get_in_reply_to ()

const char *
g_mime_message_get_in_reply_to (GMimeMessage *message);

Gets the first recovered message-id from the first In-Reply-To header, skipping malformed IDs and unrelated text without rewriting the header.

Parameters

message

a GMimeMessage

 

Returns

the message-id being replied to, or NULL if absent or no valid ID could be recovered.

[nullable]


g_mime_message_set_resent_message_id ()

void
g_mime_message_set_resent_message_id (GMimeMessage *message,
                                      const char *message_id);

Sets the Resent-Message-Id header after normalizing a complete message-id. Invalid values, including NULL, are programming errors and leave the message unchanged. Assigning the already loaded ID preserves the raw header. Changed values update only the first Resent-Message-Id header, preserving older resent blocks.

Parameters

message

a GMimeMessage

 

message_id

a UTF-8 message-id, with or without angle brackets

 

g_mime_message_get_resent_message_id ()

const char *
g_mime_message_get_resent_message_id (GMimeMessage *message);

Gets the parsed ID from the first Resent-Message-Id header.

Parameters

message

a GMimeMessage

 

Returns

the resent message-id, or NULL if absent or malformed.

[nullable]


g_mime_message_get_references ()

GMimeMessageIdList *
g_mime_message_get_references (GMimeMessage *message);

Gets the persistent, mutable References list. Editing it updates the References header, removing all matching headers when the list becomes empty. Raw-header edits clear this same list; the next getter reloads it from the first matching header without rewriting it. Editing the cleared list instead replaces the header with those new contents. The caller may retain its own reference; the list stops updating the message after the message is finalized.

Parameters

message

a GMimeMessage

 

Returns

the message's References list.

[transfer none]


g_mime_message_set_mime_part ()

void
g_mime_message_set_mime_part (GMimeMessage *message,
                              GMimeEntity *mime_part);

Set the root-level MIME part of the message.

Parameters

message

A GMimeMessage

 

mime_part

The root-level MIME Part

 

g_mime_message_get_mime_part ()

GMimeEntity *
g_mime_message_get_mime_part (GMimeMessage *message);

Gets the toplevel MIME part contained within message .

Parameters

message

A GMimeMessage

 

Returns

the toplevel MIME part of message , or NULL if none is present.

[nullable][transfer none]


g_mime_message_get_body_parts ()

GPtrArray *
g_mime_message_get_body_parts (GMimeMessage *message);

Gets all non-multipart body entities in depth-first order, including inline and attachment parts. Message parts are included as leaves; their embedded message bodies are not traversed.

Unlike MimeKit's lazy BodyParts enumeration, this returns a membership snapshot. The entities are retained original instances, not clones. Changes to their properties remain visible through the message, but changing the array does not change the MIME tree. Releasing the message or removing parts from its tree does not invalidate the snapshot.

Parameters

message

a GMimeMessage

 

Returns

a newly allocated array owning its entity references, empty when there are no body parts. Elements are borrowed from the array; retain them separately to outlive it. Free the array with g_ptr_array_unref().

[transfer container][element-type GMimeEntity]


g_mime_message_get_attachments ()

GPtrArray *
g_mime_message_get_attachments (GMimeMessage *message);

Gets the entities from g_mime_message_get_body_parts() whose Content-Disposition is "attachment". Multipart containers themselves are excluded even when marked as attachments, but their children are visited. Inline entities with filenames are not attachments. Attached messages are included without traversing their embedded bodies.

The result has the same depth-first ordering, snapshot membership, and shared entity ownership as g_mime_message_get_body_parts(). Attachment status is evaluated at the time of this call, not tracked by the array.

Parameters

message

a GMimeMessage

 

Returns

a newly allocated array owning its entity references, empty when there are no attachments. Elements are borrowed from the array; retain them separately to outlive it. Free the array with g_ptr_array_unref().

[transfer container][element-type GMimeEntity]


g_mime_message_try_get_entity ()

gboolean
g_mime_message_try_get_entity (GMimeMessage *message,
                               const char *path_specifier,
                               GMimeEntity **entity);

Looks up an entity directly, including inside attached messages. Multipart children are numbered from 1. A non-multipart message body is part 1; a multipart message body is part 0, and its children omit that 0. For example, "3.0" selects the multipart body of an attached message in part 3, while "3.1" selects its first child.

Components contain only ASCII decimal digits and must fit in a signed 32-bit integer. Leading zeros are accepted. A 0 component can only select a multipart message body and must be the final component. Empty, malformed, overflowing, or nonexistent paths return FALSE and clear entity . The returned entity is borrowed from the message tree.

Lookup is iterative and follows only the specified path, not siblings. Path specifiers use the same numbering as GMimeIterator.

Parameters

message

a GMimeMessage

 

path_specifier

a dot-separated MIME path

 

entity

the entity found, or NULL.

[out][transfer none][nullable]

Returns

TRUE if the entity exists, or FALSE otherwise.


g_mime_message_foreach ()

void
g_mime_message_foreach (GMimeMessage *message,
                        GMimeEntityForeachFunc callback,
                        gpointer user_data);

Recursively calls callback on each of the mime parts in the mime message.

Parameters

message

A GMimeMessage

 

callback

function to call on each of the mime parts contained by the mime message.

[scope call]

user_data

user-supplied callback data

 

g_mime_message_get_body ()

GMimeEntity *
g_mime_message_get_body (GMimeMessage *message);

Attempts to identify the MIME part containing the body of the message.

Parameters

message

A GMimeMessage

 

Returns

a GMimeEntity containing the textual content that appears to be the main body of the message, or NULL 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.

[nullable][transfer none]


g_mime_message_get_text_body ()

char *
g_mime_message_get_text_body (GMimeMessage *message,
                              GError **error);

Gets the decoded plain-text body using g_mime_message_get_text_body_with_format() with GMIME_TEXT_FORMAT_PLAIN. Flowed text matches plain text, but its flow and space-stuffing are not converted to fixed text.

Parameters

message

a GMimeMessage

 

error

return location for an error, or NULL

 

Returns

UTF-8 text, or NULL if no body matches or decoding fails. An empty body returns an allocated empty string.

[nullable][transfer full]


g_mime_message_get_html_body ()

char *
g_mime_message_get_html_body (GMimeMessage *message,
                              GError **error);

Gets the decoded HTML body using g_mime_message_get_text_body_with_format() with GMIME_TEXT_FORMAT_HTML. No markup conversion or sanitization is done.

Parameters

message

a GMimeMessage

 

error

return location for an error, or NULL

 

Returns

UTF-8 HTML, or NULL if no body matches or decoding fails. An empty body returns an allocated empty string.

[nullable][transfer full]


g_mime_message_get_text_body_with_format ()

char *
g_mime_message_get_text_body_with_format
                               (GMimeMessage *message,
                                GMimeTextFormat format,
                                GError **error);

Selects and decodes a text body without modifying the MIME tree. Multipart selection uses g_mime_multipart_try_get_value(), including alternative and related overrides. A standalone text body must match format and must not be an attachment. Embedded messages are not searched. Unknown formats and GMIME_TEXT_FORMAT_COMPRESSED_RICH_TEXT have no match.

Transfer encoding is decoded before charset conversion. A supported Content-Type charset takes precedence, followed by a UTF-8/UTF-16 BOM, an HTML meta charset in the first 1024 decoded bytes, then UTF-8. Declared charsets, meta charsets and UTF-16 BOMs use replacement decoding: malformed Unicode sequences become U+FFFD, other malformed input becomes '?'. HTML meta UTF-16 declarations are remapped to strict UTF-8. The default UTF-8 and UTF-8 BOM decoders are also strict and retry the whole body as ISO-8859-1 on malformed input, like MimeKit. Charset mappings follow native iconv rather than managed codepage best-fit tables. Incomplete final characters are also handled, unlike MimeKit versions whose charset filter omits decoder finalization at EOF. Newlines follow the default GMimeFormatOptions; bare CRs and Unicode BOMs are retained. No final newline is added. Flowed text is not unflowed, and formats are neither converted nor sanitized.

Missing bodies return NULL without an error. Selected text parts with absent or empty content return an allocated empty string. Decoded NULs report G_CONVERT_ERROR_EMBEDDED_NUL, other conversion failures report G_CONVERT_ERROR, and content/stream failures report GMIME_ERROR. No error returns partial text. Source-backed content must remain open and unchanged; successful decoding rewinds its stream, but failures may leave it advanced.

Parameters

message

a GMimeMessage

 

format

the requested text format

 

error

return location for an error, or NULL

 

Returns

UTF-8 text, or NULL if no body matches or decoding fails.

[nullable][transfer full]


g_mime_message_get_autocrypt_header ()

GMimeAutocryptHeader *
g_mime_message_get_autocrypt_header (GMimeMessage *message,
                                     GDateTime *now);

Creates a new GMimeAutocryptHeader 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 NULL. 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 GMimeAutocryptHeader will be returned for the sender, but it will be incomplete (see g_mime_autocrypt_header_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 NULL)

Parameters

message

a GMimeMessage object.

 

now

a GDateTime object, or NULL.

[nullable]

Returns

a new GMimeAutocryptHeader object, or NULL if the message should be ignored for purposes of Autocrypt.

[nullable][transfer full]


g_mime_message_get_autocrypt_gossip_headers_from_inner_part ()

GMimeAutocryptHeaderList *
g_mime_message_get_autocrypt_gossip_headers_from_inner_part
                               (GMimeMessage *message,
                                GDateTime *now,
                                GMimeEntity *inner_part);

Extracts Autocrypt-Gossip headers matching an address in the outer message's To, Cc, or Reply-To fields.

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 g_mime_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 GMimeAutocryptHeader 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 To, Cc, or Reply-To

  • 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 NULL

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 NULL)

Parameters

message

a GMimeMessage object.

 

now

a GDateTime object, or NULL.

[nullable]

inner_part

a GMimeEntity which is the cleartext part of the inner message

 

Returns

a new GMimeAutocryptHeaderList object, or NULL on error.

[nullable][transfer full]


g_mime_message_get_autocrypt_gossip_headers ()

GMimeAutocryptHeaderList *
g_mime_message_get_autocrypt_gossip_headers
                               (GMimeMessage *message,
                                GDateTime *now,
                                gpgme_ctx_t ctx,
                                GError **err);

Extracts Autocrypt-Gossip headers matching To, Cc, or Reply-To.

Returns the same object as g_mime_message_get_autocrypt_gossip_headers_from_inner_part(), but handles decryption and cleanup automatically.

Configure network and session-key policy on ctx before calling.

If the message is not actually an encrypted message, returns NULL: it should be ignored for purposes of evaluating gossip.

If decryption fails, returns NULL. In this case, an exception will be set on err to provide information about the decryption failure.

[skip]

Parameters

message

a GMimeMessage object, which is expected to be encrypted.

 

now

a GDateTime object, or NULL.

[nullable]

ctx

a borrowed GPGME OpenPGP context

 

err

a GError (can be NULL)

 

Returns

a new GMimeAutocryptHeaderList object, or NULL on error.

[nullable][transfer full]

Types and Values

enum GMimeAddressType

An address type.

Members

GMIME_ADDRESS_TYPE_SENDER

Represents the addresses in the Sender header.

 

GMIME_ADDRESS_TYPE_FROM

Represents the addresses in the From header.

 

GMIME_ADDRESS_TYPE_REPLY_TO

Represents the addresses in the Reply-To header.

 

GMIME_ADDRESS_TYPE_TO

Represents the recipients in the To header.

 

GMIME_ADDRESS_TYPE_CC

Represents the recipients in the Cc header.

 

GMIME_ADDRESS_TYPE_BCC

Represents the recipients in the Bcc header.

 

GMIME_ADDRESS_TYPE_RESENT_FROM

Represents the authors in Resent-From headers.

 

GMIME_ADDRESS_TYPE_RESENT_REPLY_TO

Represents the addresses in Resent-Reply-To headers.

 

GMIME_ADDRESS_TYPE_RESENT_TO

Represents the recipients in Resent-To headers.

 

GMIME_ADDRESS_TYPE_RESENT_CC

Represents the recipients in Resent-Cc headers.

 

GMIME_ADDRESS_TYPE_RESENT_BCC

Represents the recipients in Resent-Bcc headers.

 

GMIME_ADDRESS_TYPE_RESENT_SENDER

Represents the addresses in Resent-Sender headers.

 

enum GMimeMessageImportance

Values of the Importance header.

Members

GMIME_MESSAGE_IMPORTANCE_LOW

Low importance.

 

GMIME_MESSAGE_IMPORTANCE_NORMAL

Normal importance.

 

GMIME_MESSAGE_IMPORTANCE_HIGH

High importance.

 

enum GMimeMessagePriority

Values of the Priority header.

Members

GMIME_MESSAGE_PRIORITY_NON_URGENT

Non-urgent priority.

 

GMIME_MESSAGE_PRIORITY_NORMAL

Normal priority.

 

GMIME_MESSAGE_PRIORITY_URGENT

Urgent priority.

 

enum GMimeXMessagePriority

Numeric values of the X-Priority header.

Members

GMIME_X_MESSAGE_PRIORITY_HIGHEST

Highest priority.

 

GMIME_X_MESSAGE_PRIORITY_HIGH

High priority.

 

GMIME_X_MESSAGE_PRIORITY_NORMAL

Normal priority.

 

GMIME_X_MESSAGE_PRIORITY_LOW

Low priority.

 

GMIME_X_MESSAGE_PRIORITY_LOWEST

Lowest priority.

 

GMimeMessage

typedef struct _GMimeMessage GMimeMessage;

A MIME Message object.