1curl_mime_init(3)                   libcurl                  curl_mime_init(3)
2
3
4

NAME

6       curl_mime_init - create a mime handle
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       curl_mime *curl_mime_init(CURL *easy_handle);
12

DESCRIPTION

14       curl_mime_init(3) creates a handle to a new empty mime structure.  This
15       mime structure can be subsequently filled using the mime API, then  at‐
16       tached  to  some  easy handle using option CURLOPT_MIMEPOST(3) within a
17       curl_easy_setopt(3) call or added as a multipart in another  mime  han‐
18       dle's part using curl_mime_subparts(3).
19
20       easy_handle  is used for part separator randomization and error report‐
21       ing. Since 7.87.0, it does not need to be the final target handle.
22
23       Using a mime handle is the recommended way to post an HTTP form, format
24       and  send  a  multi-part  email with SMTP or upload such an email to an
25       IMAP server.
26

EXAMPLE

28        CURL *easy = curl_easy_init();
29        curl_mime *mime;
30        curl_mimepart *part;
31
32        /* Build an HTTP form with a single field named "data", */
33        mime = curl_mime_init(easy);
34        part = curl_mime_addpart(mime);
35        curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
36        curl_mime_name(part, "data");
37
38        /* Post and send it. */
39        curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
40        curl_easy_setopt(easy, CURLOPT_URL, "https://example.com");
41        curl_easy_perform(easy);
42
43        /* Clean-up. */
44        curl_easy_cleanup(easy);
45        curl_mime_free(mime);
46

AVAILABILITY

48       As long as at least one of HTTP, SMTP or  IMAP  is  enabled.  Added  in
49       7.56.0.
50

RETURN VALUE

52       A mime struct handle, or NULL upon failure.
53

SEE ALSO

55       curl_mime_addpart(3),  curl_mime_subparts(3),  curl_mime_free(3),  CUR‐
56       LOPT_MIMEPOST(3)
57
58
59
60libcurl 8.2.1                   April 26, 2023               curl_mime_init(3)
Impressum