1curl_mime_init(3) libcurl Manual curl_mime_init(3)
2
3
4
6 curl_mime_init - create a mime handle
7
9 #include <curl/curl.h>
10
11 curl_mime * curl_mime_init(CURL * easy_handle);
12
14 curl_mime_init(3) creates a handle to a new empty mime structure
15 intended to be used with easy_handle. This mime structure can be subseā
16 quently filled using the mime API, then attached to easy_handle using
17 option CURLOPT_MIMEPOST(3) within a curl_easy_setopt(3) call.
18
19 Using a mime handle is the recommended way to post an HTTP form, format
20 and send a multi-part e-mail with SMTP or upload such an e-mail to an
21 IMAP server.
22
23
25 As long as at least one of HTTP, SMTP or IMAP is enabled. Added in
26 7.56.0.
27
29 A mime struct handle, or NULL upon failure.
30
32 CURL *easy = curl_easy_init();
33 curl_mime *mime;
34 curl_mimepart *part;
35
36 /* Build an HTTP form with a single field named "data", */
37 mime = curl_mime_init(easy);
38 part = curl_mime_addpart(mime);
39 curl_mime_data(part, "This is the field data", CURL_ZERO_TERMINATED);
40 curl_mime_name(part, "data");
41
42 /* Post and send it. */
43 curl_easy_setopt(easy, CURLOPT_MIMEPOST, mime);
44 curl_easy_setopt(easy, CURLOPT_URL, "http://example.com");
45 curl_easy_perform(easy);
46
47 /* Clean-up. */
48 curl_easy_cleanup(easy);
49 curl_mime_free(mime);
50
51
53 curl_mime_addpart(3), curl_mime_free(3), CURLOPT_MIMEPOST(3)
54
55
56
57libcurl 7.61.1 September 22, 2017 curl_mime_init(3)