Defines functions and structs for message handling. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <time.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/param.h>
#include <errno.h>
#include "cmime_address.h"
#include "cmime_list.h"
#include "cmime_header.h"
#include "cmime_part.h"
#include "cmime_util.h"
#include "cmime_string.h"
Go to the source code of this file.
Data Structures | |
struct | CMimeMessage_T |
Represents an email message. More... | |
Macros | |
#define | cmime_message_get_sender(message) (message->sender) |
#define | cmime_message_get_headers(message) (message->headers) |
#define | cmime_message_get_recipients(message) (message->recipients) |
#define | cmime_message_get_boundary(message) (message->boundary) |
#define | cmime_message_part_count(message) (message->parts->size) |
Return number of mime parts. More... | |
#define | cmime_message_part_first(message) ((CMimePart_T *)cmime_list_head(message->parts)->data) |
#define | cmime_message_part_last(message) ((CMimePart_T *)cmime_list_tail(message->parts)->data) |
Enumerations | |
enum | CMimeBoundaryType_T { CMIME_BOUNDARY_OPEN, CMIME_BOUNDARY_CLOSE } |
Possible types of boundaries. More... | |
enum | CMimeMultipartType_T { CMIME_MULTIPART_MIXED, CMIME_MULTIPART_DIGEST, CMIME_MULTIPART_MESSAGE, CMIME_MULTIPART_ALTERNATIVE, CMIME_MULTIPART_RELATED } |
Possible multipart mime subtypes. More... | |
Functions | |
CMimeMessage_T * | cmime_message_new (void) |
Creates a new CMimeMessage_T object. More... | |
void | cmime_message_free (CMimeMessage_T *message) |
Free a CMimeMessage_T object. More... | |
void | cmime_message_set_sender (CMimeMessage_T *message, const char *sender) |
Add sender to CMimeMessage_T object. If sender already exists, it will be overwritten. More... | |
void | cmime_message_set_sender_encode (CMimeMessage_T *message, const char *sender) |
Add sender to CMimeMessage_T object and convert to 7 bit mime encoded string based on RFC 2047. If sender already exists, it will be overwritten. More... | |
char * | cmime_message_get_sender_string (CMimeMessage_T *message) |
Get sender of a CMimeMessage_T object as string. More... | |
void | cmime_message_set_message_id (CMimeMessage_T *message, const char *mid) |
Set message id to CMimeMessage_T object, if alreay exists, value will be overwritten. More... | |
char * | cmime_message_get_message_id (CMimeMessage_T *message) |
Get MessageID of message object. More... | |
char * | cmime_message_generate_message_id (void) |
Generate a message id. More... | |
void | cmime_message_add_generated_message_id (CMimeMessage_T *message) |
Add a newly generated message id to a CMimeMessage_T object. More... | |
int | cmime_message_set_header (CMimeMessage_T *message, const char *header) |
Set a header to message object. If header already exists, it will be overwritten. More... | |
CMimeHeader_T * | cmime_message_get_header (CMimeMessage_T *message, const char *header) |
Get header for given key. More... | |
int | cmime_message_add_recipient (CMimeMessage_T *message, const char *recipient, CMimeAddressType_T t) |
Add recipient to message. More... | |
int | cmime_message_add_recipient_encode (CMimeMessage_T *message, const char *recipient, CMimeAddressType_T t) |
Add recipient to message and convert to 7 bit mime encoded string based on RFC 2047. More... | |
int | cmime_message_add_recipient_to (CMimeMessage_T *message, const char *recipient) |
Add To recipient to message. More... | |
int | cmime_message_add_recipient_cc (CMimeMessage_T *message, const char *recipient) |
Add Cc recipient to message. More... | |
int | cmime_message_add_recipient_bcc (CMimeMessage_T *message, const char *recipient) |
Add Bcc recipient to message. More... | |
void | cmime_message_set_content_type (CMimeMessage_T *message, const char *s) |
Set Content-Type header. More... | |
char * | cmime_message_get_content_type (CMimeMessage_T *message) |
Get Content-Type header value. More... | |
void | cmime_message_set_content_transfer_encoding (CMimeMessage_T *message, const char *s) |
set Content-Transfer-Encoding value More... | |
char * | cmime_message_get_content_transfer_encoding (CMimeMessage_T *message) |
Get Content-Transfer-Encoding value. More... | |
void | cmime_message_set_content_id (CMimeMessage_T *message, const char *s) |
Set Content-ID header value. More... | |
char * | cmime_message_get_content_id (CMimeMessage_T *message) |
Get Content-ID header value. More... | |
void | cmime_message_set_content_description (CMimeMessage_T *message, const char *s) |
Set Content-Description value. More... | |
char * | cmime_message_get_content_description (CMimeMessage_T *message) |
Get Content-Description header value. More... | |
void | cmime_message_set_mime_version (CMimeMessage_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. More... | |
char * | cmime_message_get_mime_version (CMimeMessage_T *message) |
Get Mime-Version header value. More... | |
void | cmime_message_set_date (CMimeMessage_T *message, const char *s) |
Set date string header. More... | |
char * | cmime_message_get_date (CMimeMessage_T *message) |
Get date string from CMimeMessage_T object. More... | |
int | cmime_message_set_date_now (CMimeMessage_T *message) |
Get current time and set date header. More... | |
void | cmime_message_set_boundary (CMimeMessage_T *message, const char *boundary) |
Set message boundary. More... | |
char * | cmime_message_generate_boundary (void) |
Generate a message boundary. More... | |
void | cmime_message_add_generated_boundary (CMimeMessage_T *message) |
Add a newly generated boundary to a CMimeMessage_T object. More... | |
int | cmime_message_from_file (CMimeMessage_T **message, const char *filename, int header_only) |
Parse given file and create a CMimeMessage_T object. More... | |
int | cmime_message_to_file (CMimeMessage_T *message, const char *filename) |
Write CMimeMessage_T object to file. More... | |
char * | cmime_message_to_string (CMimeMessage_T *message) |
Return a message object as string. More... | |
int | cmime_message_from_string (CMimeMessage_T **message, const char *content, int header_only) |
Parse given string and create a new CMimeMessage_T object. More... | |
void | cmime_message_set_subject (CMimeMessage_T *message, const char *s) |
Set message subject. More... | |
void | cmime_message_set_subject_encode (CMimeMessage_T *message, const char *s) |
Set message subject and convert to 7 bit mime encoded string based on RFC 2047. More... | |
char * | cmime_message_get_subject (CMimeMessage_T *message) |
Get the subject string from CMimeMessage_T object. More... | |
void | cmime_message_prepend_subject (CMimeMessage_T *message, const char *s) |
prepend string to subject More... | |
void | cmime_message_append_subject (CMimeMessage_T *message, const char *s) |
append string to subject More... | |
int | cmime_message_set_body (CMimeMessage_T *message, const char *content) |
Set plain body to non multipart message. More... | |
int | cmime_message_append_part (CMimeMessage_T *message, CMimePart_T *part) |
Append mime part to message object and generate boundary if necessary. More... | |
void | cmime_message_add_attachment (CMimeMessage_T *message, char *attachment) |
add attachment to message More... | |
CMimeMessage_T * | cmime_message_create_skeleton (const char *sender, const char *recipient, const char *subject) |
create message skeleton with basic header information More... | |
int | cmime_message_part_remove (CMimeMessage_T *message, CMimePart_T *part) |
Remove a mime part from message. More... | |
int | cmime_message_add_child_part (CMimeMessage_T *message, CMimePart_T *part, CMimePart_T *child, CMimeMultipartType_T subtype) |
Add a child part to given mimepart, set content type and generate a boundary if necessary. More... | |
Defines functions and structs for message handling.
#define cmime_message_get_boundary | ( | message | ) | (message->boundary) |
#define cmime_message_get_headers | ( | message | ) | (message->headers) |
#define cmime_message_get_recipients | ( | message | ) | (message->recipients) |
#define cmime_message_get_sender | ( | message | ) | (message->sender) |
cmime_message_part_count | ( | message | ) | (message->parts->size) |
Return number of mime parts.
message | a CMimeMessage_T obejct |
#define cmime_message_part_first | ( | message | ) | ((CMimePart_T *)cmime_list_head(message->parts)->data) |
#define cmime_message_part_last | ( | message | ) | ((CMimePart_T *)cmime_list_tail(message->parts)->data) |
enum CMimeBoundaryType_T |
enum CMimeMultipartType_T |
void cmime_message_add_attachment | ( | CMimeMessage_T * | message, |
char * | attachment | ||
) |
add attachment to message
message | a CMimeMessage_T object |
attachment | a file pointer |
int cmime_message_add_child_part | ( | CMimeMessage_T * | message, |
CMimePart_T * | part, | ||
CMimePart_T * | child, | ||
CMimeMultipartType_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 cmime_message_add_generated_boundary | ( | CMimeMessage_T * | message | ) |
Add a newly generated boundary to a CMimeMessage_T object.
message | a CMimeMessage_T object |
void cmime_message_add_generated_message_id | ( | CMimeMessage_T * | message | ) |
Add a newly generated message id to a CMimeMessage_T object.
message | a CMimeMessage_T object |
int cmime_message_add_recipient | ( | CMimeMessage_T * | message, |
const char * | recipient, | ||
CMimeAddressType_T | t | ||
) |
Add recipient to message.
message | a CMimeMessage_T object |
recipient | a recipient string |
t | CMimeAddressType_T recipient type |
int cmime_message_add_recipient_bcc | ( | CMimeMessage_T * | message, |
const char * | recipient | ||
) |
Add Bcc recipient to message.
message | a CMimeMessage_T object |
recipient | a recipient string |
int cmime_message_add_recipient_cc | ( | CMimeMessage_T * | message, |
const char * | recipient | ||
) |
Add Cc recipient to message.
message | a CMimeMessage_T object |
recipient | a recipient string |
int cmime_message_add_recipient_encode | ( | CMimeMessage_T * | message, |
const char * | recipient, | ||
CMimeAddressType_T | t | ||
) |
Add recipient to message and convert to 7 bit mime encoded string based on RFC 2047.
message | a CMimeMessage_T object |
recipient | a recipient string |
t | CMimeAddressType_T recipient type |
int cmime_message_add_recipient_to | ( | CMimeMessage_T * | message, |
const char * | recipient | ||
) |
Add To recipient to message.
message | a CMimeMessage_T object |
recipient | a recipient string |
int cmime_message_append_part | ( | CMimeMessage_T * | message, |
CMimePart_T * | part | ||
) |
Append mime part to message object and generate boundary if necessary.
message | a CMimeMessage_T object |
part | a CMimePart_T part |
void cmime_message_append_subject | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
append string to subject
message | a CMimeMessage_T object |
s | a append string for subject |
CMimeMessage_T* cmime_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 cmime_message_free | ( | CMimeMessage_T * | message | ) |
int cmime_message_from_file | ( | CMimeMessage_T ** | message, |
const char * | filename, | ||
int | header_only | ||
) |
Parse given file and create a CMimeMessage_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 cmime_message_from_string | ( | CMimeMessage_T ** | message, |
const char * | content, | ||
int | header_only | ||
) |
Parse given string and create a new CMimeMessage_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* cmime_message_generate_boundary | ( | void | ) |
char* cmime_message_generate_message_id | ( | void | ) |
Generate a message id.
char* cmime_message_get_content_description | ( | CMimeMessage_T * | message | ) |
Get Content-Description header value.
message | a CMimeMessage_T object |
char* cmime_message_get_content_id | ( | CMimeMessage_T * | message | ) |
Get Content-ID header value.
message | a CMimeMessage_T object |
char* cmime_message_get_content_transfer_encoding | ( | CMimeMessage_T * | message | ) |
Get Content-Transfer-Encoding value.
message | a CMimeMessage_T object |
char* cmime_message_get_content_type | ( | CMimeMessage_T * | message | ) |
Get Content-Type header value.
message | a CMimeMessage_T object |
char* cmime_message_get_date | ( | CMimeMessage_T * | message | ) |
Get date string from CMimeMessage_T object.
message | a CMimeMessage_T object |
CMimeHeader_T* cmime_message_get_header | ( | CMimeMessage_T * | message, |
const char * | header | ||
) |
Get header for given key.
message | a CMimeMessage_T object |
header | name of header to search for |
char* cmime_message_get_message_id | ( | CMimeMessage_T * | message | ) |
Get MessageID of message object.
message | a CMimeMessage_T object |
char* cmime_message_get_mime_version | ( | CMimeMessage_T * | message | ) |
Get Mime-Version header value.
message | a CMimeMessage_T object |
char* cmime_message_get_sender_string | ( | CMimeMessage_T * | message | ) |
Get sender of a CMimeMessage_T object as string.
message | a CMimeMessage_T object |
char* cmime_message_get_subject | ( | CMimeMessage_T * | message | ) |
Get the subject string from CMimeMessage_T object.
message | a CMimeMessage_T object |
CMimeMessage_T* cmime_message_new | ( | void | ) |
Creates a new CMimeMessage_T object.
int cmime_message_part_remove | ( | CMimeMessage_T * | message, |
CMimePart_T * | part | ||
) |
Remove a mime part from message.
message | a CMimeMessage_T object |
part | the mime part which should be removed |
void cmime_message_prepend_subject | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
prepend string to subject
message | a CMimeMessage_T object |
s | string to prepend |
int cmime_message_set_body | ( | CMimeMessage_T * | message, |
const char * | content | ||
) |
Set plain body to non multipart message.
message | a CMimeMessage_T object |
content | body content |
void cmime_message_set_boundary | ( | CMimeMessage_T * | message, |
const char * | boundary | ||
) |
Set message boundary.
message | a CMimeMessage_T object |
boundary | the boundary to set |
void cmime_message_set_content_description | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
Set Content-Description value.
message | a CMimeMessage_T object |
s | Content-Description header value |
void cmime_message_set_content_id | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
Set Content-ID header value.
message | a CMimeMessage_T object |
s | Content-ID header value |
void cmime_message_set_content_transfer_encoding | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
set Content-Transfer-Encoding value
message | a CMimeMessage_T object |
s | Content-Transfer-Encoding value |
void cmime_message_set_content_type | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
Set Content-Type header.
message | a CMimeMessage_T object |
s | Content-Type string |
void cmime_message_set_date | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
Set date string header.
message | a CMimeMessage_T object |
s | date string |
int cmime_message_set_date_now | ( | CMimeMessage_T * | message | ) |
Get current time and set date header.
message | a CMimeMessage_T object |
int cmime_message_set_header | ( | CMimeMessage_T * | message, |
const char * | header | ||
) |
Set a header to message object. If header already exists, it will be overwritten.
message | a CMimeMessage_T object |
header | full header string |
void cmime_message_set_message_id | ( | CMimeMessage_T * | message, |
const char * | mid | ||
) |
Set message id to CMimeMessage_T object, if alreay exists, value will be overwritten.
message | a CMimeMessage_T object |
mid | message id string |
void cmime_message_set_mime_version | ( | CMimeMessage_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 CMimeMessage_T object |
s | Mime-Version header value |
void cmime_message_set_sender | ( | CMimeMessage_T * | message, |
const char * | sender | ||
) |
Add sender to CMimeMessage_T object. If sender already exists, it will be overwritten.
message | a CMimeMessage_T obect |
sender | sender string |
void cmime_message_set_sender_encode | ( | CMimeMessage_T * | message, |
const char * | sender | ||
) |
Add sender to CMimeMessage_T object and convert to 7 bit mime encoded string based on RFC 2047. If sender already exists, it will be overwritten.
message | a CMimeMessage_T obect |
sender | sender string |
void cmime_message_set_subject | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
Set message subject.
message | a CMimeMessage_T object |
s | the subject string |
void cmime_message_set_subject_encode | ( | CMimeMessage_T * | message, |
const char * | s | ||
) |
Set message subject and convert to 7 bit mime encoded string based on RFC 2047.
message | a CMimeMessage_T object |
s | the subject string |
int cmime_message_to_file | ( | CMimeMessage_T * | message, |
const char * | filename | ||
) |
Write CMimeMessage_T object to file.
message | a CMimeMessage_T object |
filename | path to file, which should be written |
char* cmime_message_to_string | ( | CMimeMessage_T * | message | ) |
Return a message object as string.
message | a CMimeMessage_T object |