1curl_mime_init(3)               libcurl Manual               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 in‐
15       tended 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  email with SMTP or upload such an email to an
21       IMAP server.
22

EXAMPLE

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

AVAILABILITY

44       As long as at least one of HTTP, SMTP or  IMAP  is  enabled.  Added  in
45       7.56.0.
46

RETURN VALUE

48       A mime struct handle, or NULL upon failure.
49

SEE ALSO

51       curl_mime_addpart(3), curl_mime_free(3), CURLOPT_MIMEPOST(3)
52
53
54
55libcurl 7.85.0                   May 17, 2022                curl_mime_init(3)
Impressum