Defines the SMFMessage_T data type and related functions. More...
#include <cmime.h>
#include "smf_core.h"
#include "smf_email_address.h"
#include "smf_header.h"
#include "smf_list.h"
#include "smf_part.h"
Go to the source code of this file.
Typedefs | |
typedef CMimeMessage_T | SMFMessage_T |
Represents an email message. | |
Enumerations | |
enum | SMFMultipartType_T { SMF_MULTIPART_MIXED, SMF_MULTIPART_DIGEST, SMF_MULTIPART_MESSAGE, SMF_MULTIPART_ALTERNATIVE, SMF_MULTIPART_RELATED } |
Possible multipart mime subtypes. More... | |
Functions | |
SMFMessage_T * | smf_message_new (void) |
Creates a new SMFMessage_T object. | |
void | smf_message_free (SMFMessage_T *message) |
Free SMFMessage_T object. | |
void | smf_message_set_sender (SMFMessage_T *message, const char *sender) |
SMFEmailAddress_T * | smf_message_get_sender (SMFMessage_T *message) |
Gets a SMFEmailAddress_T object of the sender from message. | |
char * | smf_message_get_sender_string (SMFMessage_T *message) |
Get sender of a SMFMessage_T object as string. | |
void | smf_message_set_message_id (SMFMessage_T *message, const char *message_id) |
Set the Message-Id on a message. | |
char * | smf_message_get_message_id (SMFMessage_T *message) |
Get the Message-Id of a message. | |
char * | smf_message_generate_message_id (void) |
int | smf_message_set_header (SMFMessage_T *message, const char *header) |
Set a header to message object. If header already exists, it will be overwritten. | |
int | smf_message_update_header (SMFMessage_T *message, const char *header, const char *value) |
Updates the header-value with the given key. | |
int | smf_message_add_header (SMFMessage_T *message, const char *header, const char *value) |
Appends the header-value to the given key. | |
SMFHeader_T * | smf_message_get_header (SMFMessage_T *message, const char *header) |
Get header for given key. | |
SMFList_T * | smf_message_get_headers (SMFMessage_T *message) |
Get list with all headers. | |
int | smf_message_remove_header (SMFMessage_T *message, const char *header_name) |
Remove a header from message. | |
int | smf_message_add_recipient (SMFMessage_T *message, const char *recipient, SMFEmailAddressType_T t) |
SMFList_T * | smf_message_get_recipients (SMFMessage_T *message) |
Get list with all recipients of message. | |
void | smf_message_set_content_type (SMFMessage_T *message, const char *s) |
Set Content-Type header. | |
char * | smf_message_get_content_type (SMFMessage_T *message) |
Get Content-Type header value. | |
void | smf_message_set_content_transfer_encoding (SMFMessage_T *message, const char *s) |
set Content-Transfer-Encoding value | |
char * | smf_message_get_content_transfer_encoding (SMFMessage_T *message) |
Get Content-Transfer-Encoding value. | |
void | smf_message_set_content_id (SMFMessage_T *message, const char *s) |
Set Content-ID header value. | |
char * | smf_message_get_content_id (SMFMessage_T *message) |
Get Content-ID header value. | |
void | smf_message_set_mime_version (SMFMessage_T *message, const char *s) |
Set Mime-Version header value. According to RFC 2045, Mime-Version header is required at the top level of a message. Not required for each body part of a multipart entity. It's required for the embedded headers of a body of type "message/rfc822" or "message/partial" if the embedded message is itself claimed to be MIME. | |
char * | smf_message_get_mime_version (SMFMessage_T *message) |
Get Mime-Version header value. | |
void | smf_message_set_date (SMFMessage_T *message, const char *s) |
Set date string header. | |
char * | smf_message_get_date (SMFMessage_T *message) |
Get date string from SMFMessage_T object. | |
int | smf_message_set_date_now (SMFMessage_T *message) |
Get current time and set date header. | |
void | smf_message_set_boundary (SMFMessage_T *message, const char *boundary) |
Set message boundary. | |
char * | smf_message_get_boundary (SMFMessage_T *message) |
Get message boundary. | |
char * | smf_message_generate_boundary (void) |
Generate a message boundary. | |
void | smf_message_add_generated_boundary (SMFMessage_T *message) |
Add a newly generated boundary to a SMFMessage_T object. | |
void | smf_message_set_subject (SMFMessage_T *message, const char *s) |
Set message subject. | |
char * | smf_message_get_subject (SMFMessage_T *message) |
Get the subject string from SMFMessage_T object. | |
int | smf_message_from_file (SMFMessage_T **message, const char *filename, int header_only) |
Parse given file and create a SMFMessage_T object. | |
int | smf_message_to_file (SMFMessage_T *message, const char *filename) |
Write SMFMessage_T object to file. | |
int | smf_message_to_fd (SMFMessage_T *message, int fd) |
Write SMFMessage_T object into the file-descriptor. | |
char * | smf_message_to_string (SMFMessage_T *message) |
Allocates a string buffer containing the contents of SMFMessage_T. | |
int | smf_message_from_string (SMFMessage_T **message, const char *content, int header_only) |
Parse given string and create a new SMFMessage_T object. | |
void | smf_message_prepend_subject (SMFMessage_T *message, const char *s) |
prepend string to subject | |
void | smf_message_append_subject (SMFMessage_T *message, const char *s) |
append string to subject | |
int | smf_message_set_body (SMFMessage_T *message, const char *content) |
Set plain body to non multipart message. | |
int | smf_message_append_part (SMFMessage_T *message, SMFPart_T *part) |
Append mime part to message object and generate boundary if necessary. | |
int | smf_message_get_part_count (SMFMessage_T *message) |
Get number of mime parts. | |
void | smf_message_add_attachment (SMFMessage_T *message, char *attachment) |
add attachment to message | |
SMFMessage_T * | smf_message_create_skeleton (const char *sender, const char *recipient, const char *subject) |
create message skeleton with basic header information | |
int | smf_message_add_child_part (SMFMessage_T *message, SMFPart_T *part, SMFPart_T *child, SMFMultipartType_T subtype) |
Add a child part to given mimepart, set content type and generate a boundary if necessary. | |
SMFPart_T * | smf_message_part_first (SMFMessage_T *message) |
Get the first mime part of a SMFMessage_T object. | |
SMFPart_T * | smf_message_part_last (SMFMessage_T *message) |
Get the last mime part of a SMFMessage_T object. | |
int | smf_message_write_skip_header (FILE *src, FILE *dest) |
Utility function to copy a message without the header The function reads a message from src but skips the header. When the body is reached, the content is written into dest. | |
Defines the SMFMessage_T data type and related functions.
SMFMessage_T represents an email message.
To create a new SMFMessage_T, use smf_message_new()
To destroy a SMFMessage_T use smf_message_free()
enum SMFMultipartType_T |
void smf_message_add_attachment | ( | SMFMessage_T * | message, |
char * | attachment | ||
) |
add attachment to message
message | a SMFMessage_T object |
attachment | a file pointer |
int smf_message_add_child_part | ( | SMFMessage_T * | message, |
SMFPart_T * | part, | ||
SMFPart_T * | child, | ||
SMFMultipartType_T | subtype | ||
) |
Add a child part to given mimepart, set content type and generate a boundary if necessary.
message | a CMimeMessage_T object |
part | the parent mime part |
child | the child mime part, which should be added |
subtype | the multipart subtype |
void smf_message_add_generated_boundary | ( | SMFMessage_T * | message | ) |
Add a newly generated boundary to a SMFMessage_T object.
message | a SMFMessage_T object |
int smf_message_add_header | ( | SMFMessage_T * | message, |
const char * | header, | ||
const char * | value | ||
) |
Appends the header-value to the given key.
If the header-entry does not exist, it will be created
message | a SMFMessage_T object |
header | The key of the header-entry to update resp. create |
value | A new value for the header-entry |
int smf_message_add_recipient | ( | SMFMessage_T * | message, |
const char * | recipient, | ||
SMFEmailAddressType_T | t | ||
) |
Add a recipient of a chosen type to the message object.
message | SMFMessage_T object |
recipient | recipient string |
t | A SMFEmailAddressType_T |
int smf_message_append_part | ( | SMFMessage_T * | message, |
SMFPart_T * | part | ||
) |
Append mime part to message object and generate boundary if necessary.
message | a SMFMessage_T object |
part | a SMFPart_T part |
void smf_message_append_subject | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
append string to subject
message | a SMFMessage_T object |
s | a append string for subject |
SMFMessage_T* smf_message_create_skeleton | ( | const char * | sender, |
const char * | recipient, | ||
const char * | subject | ||
) |
create message skeleton with basic header information
sender | a from sender |
recipient | a to recipient |
subject | a subject string |
void smf_message_free | ( | SMFMessage_T * | message | ) |
Free SMFMessage_T object.
Free SMFMessage_T object
message | SMFMessage_T object |
int smf_message_from_file | ( | SMFMessage_T ** | message, |
const char * | filename, | ||
int | header_only | ||
) |
Parse given file and create a SMFMessage_T object.
message | out param to return the new message object |
filename | path to message file |
header_only | parse only message headers, 1 = tue, 0 = false |
int smf_message_from_string | ( | SMFMessage_T ** | message, |
const char * | content, | ||
int | header_only | ||
) |
Parse given string and create a new SMFMessage_T object.
message | out param to return the new message object |
content | message string to parse |
header_only | parse only message headers, 1 = tue, 0 = false |
char* smf_message_generate_boundary | ( | void | ) |
Generate a message boundary.
char* smf_message_generate_message_id | ( | void | ) |
Generates a unique Message-Id.
char* smf_message_get_boundary | ( | SMFMessage_T * | message | ) |
Get message boundary.
message | a SMFMessage_T object |
char* smf_message_get_content_id | ( | SMFMessage_T * | message | ) |
Get Content-ID header value.
message | a SMFMessage_T object |
char* smf_message_get_content_transfer_encoding | ( | SMFMessage_T * | message | ) |
Get Content-Transfer-Encoding value.
message | a SMFMessage_T object |
char* smf_message_get_content_type | ( | SMFMessage_T * | message | ) |
Get Content-Type header value.
message | a SMFMessage_T object |
char* smf_message_get_date | ( | SMFMessage_T * | message | ) |
Get date string from SMFMessage_T object.
message | a SMFMessage_T object |
SMFHeader_T* smf_message_get_header | ( | SMFMessage_T * | message, |
const char * | header | ||
) |
Get header for given key.
message | a SMFMessage_T object |
header | name of header to search for |
SMFList_T* smf_message_get_headers | ( | SMFMessage_T * | message | ) |
Get list with all headers.
message | a SMFMessage_T object |
char* smf_message_get_message_id | ( | SMFMessage_T * | message | ) |
Get the Message-Id of a message.
message | SMFMessage_T object |
char* smf_message_get_mime_version | ( | SMFMessage_T * | message | ) |
Get Mime-Version header value.
message | a SMFMessage_T object |
int smf_message_get_part_count | ( | SMFMessage_T * | message | ) |
Get number of mime parts.
message | a SMFMessage_T object |
SMFList_T* smf_message_get_recipients | ( | SMFMessage_T * | message | ) |
Get list with all recipients of message.
message | a SMFMessage_T object |
SMFEmailAddress_T* smf_message_get_sender | ( | SMFMessage_T * | message | ) |
Gets a SMFEmailAddress_T object of the sender from message.
Gets the email address of the sender from message.
message | SMFmessage_T object |
char* smf_message_get_sender_string | ( | SMFMessage_T * | message | ) |
Get sender of a SMFMessage_T object as string.
message | a SMFMessage_T object |
char* smf_message_get_subject | ( | SMFMessage_T * | message | ) |
Get the subject string from SMFMessage_T object.
message | a SMFMessage_T object |
SMFMessage_T* smf_message_new | ( | void | ) |
Creates a new SMFMessage_T object.
Creates a new SMFMessage_T object
SMFPart_T* smf_message_part_first | ( | SMFMessage_T * | message | ) |
Get the first mime part of a SMFMessage_T object.
message | a SMFMessage_T object |
SMFPart_T* smf_message_part_last | ( | SMFMessage_T * | message | ) |
Get the last mime part of a SMFMessage_T object.
message | a SMFMessage_T object |
void smf_message_prepend_subject | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
prepend string to subject
message | a SMFMessage_T object |
s | string to prepend |
int smf_message_remove_header | ( | SMFMessage_T * | message, |
const char * | header_name | ||
) |
Remove a header from message.
message | a SMFMessage_T object |
header_name | name of the header |
int smf_message_set_body | ( | SMFMessage_T * | message, |
const char * | content | ||
) |
Set plain body to non multipart message.
message | a SMFMessage_T object |
content | body content |
void smf_message_set_boundary | ( | SMFMessage_T * | message, |
const char * | boundary | ||
) |
Set message boundary.
message | a SMFMessage_T object |
boundary | the boundary to set |
void smf_message_set_content_id | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
Set Content-ID header value.
message | a SMFMessage_T object |
s | Content-ID header value |
void smf_message_set_content_transfer_encoding | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
set Content-Transfer-Encoding value
message | a SMFMessage_T object |
s | Content-Transfer-Encoding value |
void smf_message_set_content_type | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
Set Content-Type header.
message | a SMFMessage_T object |
s | Content-Type string |
void smf_message_set_date | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
Set date string header.
message | a SMFMessage_T object |
s | date string |
int smf_message_set_date_now | ( | SMFMessage_T * | message | ) |
Get current time and set date header.
message | a SMFMessage_T object |
int smf_message_set_header | ( | SMFMessage_T * | message, |
const char * | header | ||
) |
Set a header to message object. If header already exists, it will be overwritten.
message | a SMFMessage_T object |
header | full header string |
void smf_message_set_message_id | ( | SMFMessage_T * | message, |
const char * | message_id | ||
) |
Set the Message-Id on a message.
message | SMFMessage_T object |
message_id | the message id |
void smf_message_set_mime_version | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
Set Mime-Version header value. According to RFC 2045, Mime-Version header is required at the top level of a message. Not required for each body part of a multipart entity. It's required for the embedded headers of a body of type "message/rfc822" or "message/partial" if the embedded message is itself claimed to be MIME.
message | a SMFMessage_T object |
s | Mime-Version header value |
void smf_message_set_sender | ( | SMFMessage_T * | message, |
const char * | sender | ||
) |
Set the sender's name and address on the message object.
message | SMFMessage_T object |
sender | The name and address of the sender |
void smf_message_set_subject | ( | SMFMessage_T * | message, |
const char * | s | ||
) |
Set message subject.
message | a SMFMessage_T object |
s | the subject string |
int smf_message_to_fd | ( | SMFMessage_T * | message, |
int | fd | ||
) |
Write SMFMessage_T object into the file-descriptor.
message | a SMFMessage_T object |
fd | the file-descriptor, where the file should be written |
int smf_message_to_file | ( | SMFMessage_T * | message, |
const char * | filename | ||
) |
Write SMFMessage_T object to file.
message | a SMFMessage_T object |
filename | path to file, which should be written |
char* smf_message_to_string | ( | SMFMessage_T * | message | ) |
Allocates a string buffer containing the contents of SMFMessage_T.
message | a SMFMessage_T object |
int smf_message_update_header | ( | SMFMessage_T * | message, |
const char * | header, | ||
const char * | value | ||
) |
Updates the header-value with the given key.
If the header-entry does not exist, it will be created
message | a SMFMessage_T object |
header | The key of the header-entry to update resp. create |
value | The new value of the header-entry |
int smf_message_write_skip_header | ( | FILE * | src, |
FILE * | dest | ||
) |
Utility function to copy a message without the header The function reads a message from src but skips the header. When the body is reached, the content is written into dest.
src | A readable FILE pointer to the source message |
dest | A writable FILE pointer to the destination message |